external HD as datadir - working, not reported, not mounted

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 31.0.6 (AIO)
  • Operating system and version (e.g., Ubuntu 24.04):
    • cat /etc/debian_version : 12.11
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • Caddy v2.10.0

Summary of the issue you are facing:

I switched the nextcloud AIO / docker data directory:

/var/lib/docker/volumes/nextcloud_aio_nextcloud_data/_data

to an external harddisk using this advice:
https://github.com/nextcloud/all-in-one?tab=readme-ov-file#how-to-change-the-default-location-of-nextclouds-datadir
and
https://github.com/nextcloud/all-in-one/discussions/890
I should mention that I never used docker before, have only a slight idea what it does, and had to google myself through keywords such as “docker images”, “docker volume” and “docker container”.

In essence, I stopped and removed the main docker container, then restarted it with

sudo docker run (+ all the standard commands…)

and

–env NEXTCLOUD_DATADIR=“/path/to/my/external/ext4/usb/harddisk”

Everything appears fine, no error messages from docker, new files are written in the new datadir on the external harddisk, just 2 things are odd:

  1. In the admin webinterface: Administration settings => System shows the wrong/old hardisk with 100 GB and reports it as half full, whereas the new, external disk would have 1 TB. I wonder what happens if the old hardisks limit is met?
    Question: Is that something I have to live with because I changed only the datadir, not dockers container location?

  2. The new disk is not mounted. It was mounted under /dev/sdb1 before I stopped the docker container. I even had an fstab entry and mounted it from there.
    Now, ‘mount -l’ and other hd tools won’t show /dev/sdb1. However, nextcloud files are visible under the mount point “/path/to/my/external/ext4/usb/harddisk” and new files appear there.
    Question: Is this because docker kind of took over the mounted disk, dismounted it and remounted it in some docker way? In short, is this normal?

Thanks for any advice.

maybe wrong permissions?

Hello @totor,

welcome to the Nextcloud community! :handshake:

this a bad prerequisite to successfully run a self-hosted system. I would recommend you read and follow 101: Self-hosting information for beginners and learn technologies relevant for you e.g. docker

this two statements don’t make any sense

and

I can not imagine any situation how your old data could be visible from old location but new data stored in new location.

I bet you missed to completely recreate your containers:

If it was started already, you will need to stop the mastercontainer, remove it (no data will be lost) and recreate it using the docker run command that you initially used). Allowed values for that variable are strings that start with / and are not equal to / . The chosen directory or volume will then be mounted to /mnt/ncdata inside the container.

but at the end best way to analyze where the problem comes from is to check what/how the data is visible inside of the container (use docker exec or docker compose exec with right container name and run ls -al /mnt/ncdata)

Also take into account the article you mentioned only covers switching the mount point of you data directory - you still must copy/sync files from old location to new destination.

and one last hint - “external harddisk” is definitely not a recommended setup for production. such devices could introduce headaches e.g. if the drives is suddenly disconnected, not initialized (quick enough) at reboot etc. if possible use internal drives for application storage.

Hello, thank you for the quick and helpful reply, I apologize for the lateness of mine: It works now.
I reinstalled AIO with --env NEXTCLOUD_DATADIR=“/path/to/my/external/ext4/usb/harddisk” and this time there were no issues.

My best guess for the above problem is that I, contrary to my memory as stated in 2., did not mount the external hdd before the first install.
The second time, I triple checked that the drive was mounted before reinstalling.

“external harddisk” is definitely not a recommended setup for production. such devices could introduce headaches e.g. if the drives is suddenly disconnected, not initialized (quick enough) at reboot etc. if possible use internal drives for application storage

Yes, I think that NEXTCLOUD_DATADIR should be the equivalent of /home on Linux or /User on Macs: Just store the user data there, probably excluding admin. That way, Nextcloud could still operate on disconnects with only user data missing. Unfortunately Nextcloud seems to store files that are crucial to the instance operation there, so that when that directory disconnects for some reason, Nextcloud can’t start.
So using an internal HDD is probably the safest method.

However, this was not an option for me because the nextcloud host machine is quite old and I couldn’t install a HDD with large capacity there. Also, the external HDD can disconnect, yes, but the data is more accessible this way. In emergencies, I could plug it out and plug it in somewhere else and access the data. I think that is an advantage!

Anyway, this topic could be closed, as the problem is solved for me. Thanks again!