Nextcloud-snap: Move the data directory on a external drive gives .ocdata file eror


I have installed nextcloud with the snap method. Everything is going well but I am out of space. So I have bought a new hard drive. The problem is that I do not manage to move the data directory to the new hard drive. Let me summarize what I have done:

  • Plug the HDD
  • Create a location /media/HDD_storage
  • Change the /etc/fstab file by adding a new line UUID=... /media/HDD_storage ext4 defaults 0 2
  • Reboot my computer to automount the disk
  • Then I have followed the guide from the github page Nextcloud-snap
 $ sudo mkdir -p /media/HDD_storage/nextcloud
 $ sudo chown -R root:root /media/HDD_storage/nextcloud
  • I stop the snap running
 $ sudo snap stop nextcloud
  • I have change the path to the new directory in the config.php file
 // ...
 'datadirectory' => '/media/HDD_storage/nextcloud/data',
 // ...
  • For the first try I did
 $ sudo cp -R /var/snap/nextcloud/common/nextcloud/data /media/HDD_storage/nextcloud/
  • The first try was not working so I tried this after removing the previous folder
 $ sudo mv /var/snap/nextcloud/common/nextcloud/data /media/HDD_storage/nextcloud/
  • Finally I restart the snap
$ sudo snap start nextcloud

Unfortunately, it does not work. I get the following error message from the browser:
Your data directory is invalid Ensure there is a file called ".ocdata" in the root of the data directory. Cannot create "data" directory This can usually be fixed by giving the webserver write access to the root directory. See

I do not understand why this file is missing because I try with mv and cp -R. After the mv command try, I move back the directory, still with mv, and I went back to the first config.php file

'datadirectory' => '/var/snap/nextcloud/common/nextcloud/data'

and know it is working again but I am still out of space.

Could someone help me to understand what is wrong?

Thanks for reading.


sorry that I probably can’t help but I am facing a very similar problem that drives me nuts. I also want the data dir to reside on an extra HDD which i mounted as my /home dir. For this reason I created a mounting point and updated the /etc/fstab by adding the UUID; I also updated the folder permissions to root.

Everything seems to work except the nextcloud snap doesn’t accept this dir. Every try to change the datadirectory in the config.php leads to server error. It somehow is related to the fact that we’re trying to use a mounting point.

In your case you might try to enable the removable media plug as described here: nextcloud snap with data-directory on external harddrive - Ask Ubuntu

Maybe this might help as well: [Solved] Snap Nextcloud Removable-Media and External storages unsuccessfully added, need help · Issue #511 · nextcloud-snap/nextcloud-snap · GitHub

Probably I shoud have mounted my HDD unter /mnt or /media area. Haven’t tried yet.

Hang in there!


I already done it but forget to write it.

SOLVED: I just move from /media/HDD_storage/nextcloud/data into /media/HDD_storage/data and set sudo chown -R root:root /media/HDD_storage. Then I correct the config.php file and everything is working now.

I do not understand why it behaves like this. At the beginning, I want to use this HDD not only for the /data directory but it seems that I am forced to.