Nextcloud mounts drive to a new mount point every reboot

I have a drive normally mounted to /media/leo/storage
after every reboot all files get moved to storage1 and after the next to storage2 and so on. I don’t know why this happens, let me know if you need further information.

config.php

<?php
$CONFIG = array (
  'instanceid' => 'oct810j9om3z',
  'passwordsalt' => '[...]',
  'secret' => '[...]',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => '[...]',
    2 => '[...]',
    3 => '[...]',
  ),
  'datadirectory' => '/media/leo/storage3',
  'dbtype' => 'mysql',
  'version' => '28.0.1.1',
  'overwrite.cli.url' => 'http://localhost',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '[...]',
  'dbpassword' => '[...]',
  'installed' => true,
  'config_is_read_only' => true,
  'mail_domain' => '[...]',
  'mail_from_address' => 'nextcloud',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_smtphost' => '[...]',
  'mail_smtpport' => '465',
  'mail_smtpauth' => 1,
  'mail_smtpname' => '[...]',
  'mail_smtppassword' => 'c[...]',
  'app_install_overwrite' => 
  array (
    0 => 'unsplash',
    1 => 'occweb',
  ),
  'defaultapp' => '',
);

To me, that sounds like a problem that exists at the operating system level and has nothing to do with Nextcloud.

How is the directory integrated? Did you put it in /etc/fstab or is it mounted by some automount mechanism?

As much information as possible. At least:

  • What Operating system

  • the echo of

    mount
    
  • the echo of

    cat /etc/fstab
    

Much luck,
ernolf

2 Likes

OS: Ubuntu 23.10

mount output:

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=5982704k,nr_inodes=1495676,mode=755,inode64)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,noexec,relatime,size=1203312k,mode=755,inode64)                                           /dev/mapper/ubuntu--vg-ubuntu--lv on / type ext4 (rw,relatime)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,inode64)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k,inode64)
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
bpf on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,relatime,mode=700)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=29,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=2305)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,pagesize=2M)
mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime)
tracefs on /sys/kernel/tracing type tracefs (rw,nosuid,nodev,noexec,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,nosuid,nodev,noexec,relatime)
configfs on /sys/kernel/config type configfs (rw,nosuid,nodev,noexec,relatime)
ramfs on /run/credentials/systemd-sysusers.service type ramfs (ro,nosuid,nodev,noexec,relatime,mode=700)
ramfs on /run/credentials/systemd-sysctl.service type ramfs (ro,nosuid,nodev,noexec,relatime,mode=700)
ramfs on /run/credentials/systemd-tmpfiles-setup-dev.service type ramfs (ro,nosuid,nodev,noexec,relatime,mode=700)
/dev/sda2 on /boot type ext4 (rw,relatime)
/var/lib/snapd/snaps/bare_5.snap on /snap/bare/5 type squashfs (ro,nodev,relatime,errors=continue,threads=single,x-gdu.hide,x-gvfs-hide)
/var/lib/snapd/snaps/core18_2812.snap on /snap/core18/2812 type squashfs (ro,nodev,relatime,errors=continue,threads=single,x-gdu.hide,x-gvfs-hide)
/var/lib/snapd/snaps/core22_1033.snap on /snap/core22/1033 type squashfs (ro,nodev,relatime,errors=continue,threads=single,x-gdu.hide,x-gvfs-hide)
/var/lib/snapd/snaps/core22_864.snap on /snap/core22/864 type squashfs (ro,nodev,relatime,errors=continue,threads=single,x-gdu.hide,x-gvfs-hide)
/var/lib/snapd/snaps/firefox_3216.snap on /snap/firefox/3216 type squashfs (ro,nodev,relatime,errors=continue,threads=single,x-gdu.hide,x-gvfs-hide)
/var/lib/snapd/snaps/firmware-updater_109.snap on /snap/firmware-updater/109 type squashfs (ro,nodev,relatime,errors=continue,threads=single,x-gdu.hide,x-gvfs-hide)
/var/lib/snapd/snaps/gnome-42-2204_141.snap on /snap/gnome-42-2204/141 type squashfs (ro,nodev,relatime,errors=continue,threads=single,x-gdu.hide,x-gvfs-hide)
/var/lib/snapd/snaps/gtk-common-themes_1535.snap on /snap/gtk-common-themes/1535 type squashfs (ro,nodev,relatime,errors=continue,threads=single,x-gdu.hide,x-gvfs-hide)
/var/lib/snapd/snaps/htop_3873.snap on /snap/htop/3873 type squashfs (ro,nodev,relatime,errors=continue,threads=single,x-gdu.hide,x-gvfs-hide)
/var/lib/snapd/snaps/snap-store_1046.snap on /snap/snap-store/1046 type squashfs (ro,nodev,relatime,errors=continue,threads=single,x-gdu.hide,x-gvfs-hide)
/var/lib/snapd/snaps/snapd_20290.snap on /snap/snapd/20290 type squashfs (ro,nodev,relatime,errors=continue,threads=single,x-gdu.hide,x-gvfs-hide)
/var/lib/snapd/snaps/vlc_3721.snap on /snap/vlc/3721 type squashfs (ro,nodev,relatime,errors=continue,threads=single,x-gdu.hide,x-gvfs-hide)
/var/lib/snapd/snaps/snapd-desktop-integration_83.snap on /snap/snapd-desktop-integration/83 type squashfs (ro,nodev,relatime,errors=continue,threads=single,x-gdu.hide,x-gvfs-hide)
/dev/mapper/ubuntu--vg-ubuntu--lv on /var/snap/firefox/common/host-hunspell type ext4 (ro,noexec,noatime)
ramfs on /run/credentials/systemd-tmpfiles-setup.service type ramfs (ro,nosuid,nodev,noexec,relatime,mode=700)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,nosuid,nodev,noexec,relatime)
ramfs on /run/credentials/systemd-resolved.service type ramfs (ro,nosuid,nodev,noexec,relatime,mode=700)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=1203308k,nr_inodes=300827,mode=700,uid=1000,gid=1000,inode64)
portal on /run/user/1000/doc type fuse.portal (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
tmpfs on /run/snapd/ns type tmpfs (rw,nosuid,nodev,noexec,relatime,size=1203312k,mode=755,inode64)
nsfs on /run/snapd/ns/snapd-desktop-integration.mnt type nsfs (rw)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
nsfs on /run/snapd/ns/firefox.mnt type nsfs (rw)
/dev/sdb1 on /media/leo/storage4 type ext4 (rw,nosuid,nodev,relatime,errors=remount-ro,uhelper=udisks2)
nsfs on /run/snapd/ns/vlc.mnt type nsfs (rw)
nsfs on /run/snapd/ns/firmware-updater.mnt type nsfs (rw)

cat /etc/fstab:

#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/ubuntu-vg/ubuntu-lv during curtin installation
/dev/disk/by-id/dm-uuid-LVM-x1YkxkG1SRAcDfXG5fLb80WIBYf1EndmEOfro4MqK9LBN6HhJyCHsXPJGypqpwr2 / ext4 defaults 0 1
# /boot was on /dev/sda2 during curtin installation
/dev/disk/by-uuid/f05bff2b-f670-4b14-90d5-1efa7c2c347c /boot ext4 defaults 0 1
/swap.img       none    swap    sw      0       0

Output of blkid:

leo@ubuntu:/etc/udev/rules.d$ sudo blkid
/dev/mapper/ubuntu--vg-ubuntu--lv: UUID="a9969ade-df63-4312-bc89-742e7d5d3a60" BLOCK_SIZE="4096" TYPE="ext4"
/dev/loop1: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/loop8: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/sdb1: LABEL="storage" UUID="4b5e263a-0641-4d48-8217-f9a2946ed0f2" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="e3efd7ec-d4b8-4092-9b26-f4c39c0b8ea8"
/dev/loop6: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/loop4: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/loop11: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/loop2: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/loop0: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/loop9: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/loop7: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/sda2: UUID="f05bff2b-f670-4b14-90d5-1efa7c2c347c" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="6a6e10a8-83f6-4002-89d1-26212fd5b211"
/dev/sda3: UUID="DES4vm-aYPR-Aiu5-m1Vg-C6h9-AbCz-V8EV42" TYPE="LVM2_member" PARTUUID="e74dbdd2-c681-4632-88fe-239a12982e2b"
/dev/sda1: PARTUUID="c51d88e1-b6cc-4743-bd4b-2fa477514d4f"
/dev/loop5: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/loop12: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/loop3: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/loop10: BLOCK_SIZE="131072" TYPE="squashfs"

I’m using /dev/sdb1 (storage)

I will check the mount options in the disks app later, but thank you for your reply now that i know that it has nothing to do with nextcloud.

1 Like

I would strongly recommend that you always use the LTS version for servers on Ubuntu. The current LTS version is 22.04 and the next one will be released in April 24 and will then also be called 24.04.
The development versions such as 23.10 are only supported for a short time and are therefore rather unsuitable for a server application.


That is what I expected. The drive is mounted by udisk2, which creates the mountpoint every time again and is not mounted on a fix mountpoint, as you need it for a server.

Add mountpoint in /etc/fstab

Create a fix mointpoint, e.g. /mnt/nc-data:

sudo mkdir -p /mnt/nc-data

add this line to /etc/fstab:

/dev/disk/by-label/storage /mnt/nc-data ext4 defaults 0 2

sudo echo "/dev/disk/by-label/storage  /mnt/nc-data  ext4  defaults  0  2" >> /etc/fstab

Change this line in your config.php:

  'datadirectory' => '/media/leo/storage3',

into

  'datadirectory' => '/mnt/nc-data',

After the next reboot, the disk will always be at /mnt/nc-data

You may have to scan your files again, to import them on the new location in the database:

sudo -u www-data php -f /var/www/nextcloud/occ files:scan --all

I hope that helps!

Much luck,
ernolf

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.