Change Nextcloud data location

Guide: Change Data Storage Location for Nextcloud Docker Installation

This guide will help you change the data storage location for your Nextcloud Docker installation to different disk mounted as /mnt/tank/

Step 1: Stop the Nextcloud Container

  1. Use right click stop in Umbrel WebUI

Step 2: Create new partition and new data directory

  1. Install xfsprogs
sudo apt update
sudo apt install xfsprogs
  1. Format and mount the partition as XFS:
sudo mkfs.xfs /dev/sdb1
sudo mount /dev/sdb1 /mnt/tank
  1. Create the new directory for Nextcloud data:
sudo mkdir -p /mnt/tank/nextcloud
  1. Set the correct permissions:
sudo chown -R www-data:www-data /mnt/tank/nextcloud

Step 3: Identify the Current Data Directory (start, run inspect, and stop again nextcloud)

  1. Inspect the Nextcloud container to find the current data directory:
docker inspect nextcloud_web_1
  1. Look for the Mounts section in the output. It will show the current source (host) and destination (container) paths for the data volume. For example:
"Mounts": [
    {
        "Type": "bind",
        "Source": "/home/umbrel/umbrel/app-data/nextcloud/data/nextcloud",
        "Destination": "/var/www/html",
        "Mode": "rw",
        "RW": true,
        "Propagation": "rprivate"
    }
]
  • Source is the current data directory on the host (e.g., /home/umbrel/umbrel/app-data/nextcloud/data/nextcloud).

  • Destination is the mount point inside the container (e.g., /var/www/html).

Step 4: Copy Existing Data to the New Location (This might take a while)

  1. Copy the existing Nextcloud data to the new location using rsync:
sudo rsync -av /home/umbrel/umbrel/app-data/nextcloud/data/nextcloud/ /mnt/tank/nextcloud/`
  1. Verify the data has been copied:
ls -la /mnt/tank/nextcloud

Step 5: Update the Docker Configuration

  1. Open the docker-compose.yml file:
sudo nano /home/umbrel/umbrel/app-data/nextcloud/docker-compose.yml
  1. Locate the volumes section for the web service and update it:
volumes:
  - /mnt/tank/nextcloud:/var/www/html
  1. Save and exit the file.

Step 6: Restart the Nextcloud Container

  1. Use right click restart in Umbrel WebUI

Step 7: Verify the Changes

  1. Log in to the Nextcloud web interface.

  2. Verify that all files, folders, and apps are accessible.

  3. Upload a new file and confirm it appears in /mnt/tank/nextcloud/data/umbrel/files.

Step 8: Clean Up the Old Data Directory (Optional)

  1. Delete the old data directory to free up space:
sudo rm -rf /home/umbrel/umbrel/app-data/nextcloud/data/nextcloud

Step 9: Ensure Persistent Mount After Reboot

  1. Find the UUID of /dev/sdb1:
sudo blkid /dev/sdb1
  1. Edit the /etc/fstab file:
sudo nano /etc/fstab
  1. Add the following line to the end of the file:
    UUID=<YOUR DISK UUID> /mnt/tank xfs defaults 0 2
    example: UUID=1190bd87-aa96-4993-8413-1c1da928fc77 /mnt/tank xfs defaults 0 2

  2. Save and exit the file.

Step 10: Final Verification

  1. Reboot the system

  2. After reboot, verify that /dev/sdb1 is mounted to /mnt/tank:

df -h /mnt/tank
  1. Check that Nextcloud is functioning correctly.

Troubleshooting

  • If the container fails to start, check the logs:
    docker logs nextcloud_web_1

  • If the mount fails after reboot, verify the /etc/fstab entry and check for errors in the system logs:
    journalctl -xe

  • If you update you need to do this again

2 Likes

Great tutorial! Thanks for this!

1 Like