Moving Nextcloud Data to external USB drive

Hello,

I am no expert but from my personal experience, I see Linux doesn’t play well with NTFS with advance apps due to permission errors. Better to use ext4.

How to Change Snap NextCloud user Data Directory?

Step 1 →

Connect the Disk and ensure it is detected and readable by Ubuntu by running command, sudo lsblk. This command should show an output with sdb or sdc (depending on number of drive installed) with your drive total capacity.

Step 2 →

Formatting the drive and mounting it under /media or /mnt (warning → Formatting the drive will erase all present data)

sudo mkdir /media/datadisk

sudo mkfs.ext4 -j -L DataDisk /dev/sdb

then

sudo blkid /dev/sdb → It will generate the disk UUID. Copy it and keep it for the next step.

sudo nano /etc/fstab → It will open up a configuration file under text edititor, don’t change anything just add below line at the end of the file → /dev/disk/by-uuid/4006fe68-879a-41ed-b4da-cc0e6bc6b4bb /media/datadisk auto nosuid,nodev,nofail,x-gvfs-show,x-gvfs-name=NewHDD 0 0 (replace the UUID of this command with your own) Now save and exit the file (CTRL+X → SHIFT+Y → ENTER)

sudo mount -a

Step 3 →

Changeing the nextcloud to the new location

sudo snap connect nextcloud:removable-media → This is to allow snap nextcloud access out of the confinement to external file system.

sudo snap stop nextcloud

sudo mv /var/snap/nextcloud/common/nextcloud/data /media/datadisk/ncdata

sudo nano /var/snap/nextcloud/current/nextcloud/config/config.php → Find the line with entry for DataDirectory and change the location to /media/datadisk/ncdata. Save and exit

sudo chown -R root:root /media/datadisk/ncdata & then sudo chmod 0770 /media/datadisk/ncdata

sudo snap start nextcloud

Last Step →

You may now need to reboot the server.

Your installation will now save all user data out to that external or second disk.

Thanks.

2 Likes