Nextcloud Snap unable to read data folder mounted in /media

On http://localhost, I simply get:

Nextcloud Error
Your data directory is invalid
Ensure there is a file called “.ocdata” in the root of the data directory.

This is an import from another Nextcloud instance, where I’ve already restored the MySQL database, and tried to set up /media/hosted/nextcloud/data/ as the data directory; I’ve already ran # snap connect nextcloud:removable-media

My configuration is as follows:

[root@zebArchDesktop ~]# grep datadirectory /var/snap/nextcloud/current/nextcloud/config/config.php
  'datadirectory' => '/media/hosted/nextcloud/data',
[root@zebArchDesktop ~]# ls -lah /media/hosted/nextcloud/data/.ocdata 
-rwxrwxrwx 1 root root 0 Jun 18 20:12 /media/hosted/nextcloud/data/.ocdata
[root@zebArchDesktop ~]# nextcloud.mysql-client 
mysql> USE nextcloud;
mysql> SELECT * FROM oc_storages WHERE id LIKE 'local%';
| id                                   | numeric_id | available | last_checked |
| local::/media/hosted/nextcloud/data/ |         13 |         1 |         NULL |
1 row in set (0.00 sec)

The Nextcloud Snap really just can’t see my data, and I found something interesting:

[root@zebArchDesktop ~]# snap run --shell nextcloud.occ
[root@zebArchDesktop root]# ls -lah /media/hosted/nextcloud/data/
total 0
drwxrwx--- 3 root root 80 Jun 21 20:10 .
drwxr-xr-x 3 root root 60 Jun 21 19:26 ..
drwxr-xr-x 4 root root 80 Jun 21 19:26 appdata_ocpuaavroxaa
-rw-r--r-- 1 root root  0 Jun 21 19:26 nextcloud.log

If I touch /media/hosted/nextcloud/data/.ocdata within the snap shell, the error goes away and my nextcloud goes live with no data files. So, it’s as if the nextcloud snap sees an parallel dimension of my /media/hosted/nextcloud/data/ folder. I have no idea how to fix this from here and get the snap to see my data folder correctly.

  1. Run the command blkid and find the UUID for your drive and write it down.

  2. Create the mount point where you want it to mount. In my case I only managed to get it to work in the /mnt/ folder

cd /mnt/
mkdir /Nextcloud/

  1. Edit your /etc/fstab file with your preferred editor and add the line below

UUID=0071900363FC570D /mnt/Nextcloud ntfs-3g utf8,uid=root,gid=root,umask=0007,noatime,x-gvfs-show 0 0


Change the UUID to the value corresponding to your unit

Remember the drive cannot be recognized by Nextcloud if it is mounted at /media/user/path.

Restart the system to apply the settings.