Move the complete data folder to NAS (NFS)

I am attempting to move the whole nextcloud-data folder onto my NAS.
Does that work? Because, what I attempted basically left me with .ocdata error, even if the file was there. Permissions seem fine.
I basically mounted my NFS path as /mnt/nas. I have to do all that as root. While I can access the folder as root, I cannot access it as a user. This might be an issue. However, how would I mount as user, if it requires root? I think that might an issue?
Thank you

which version: nfs3 or nfs4?

the user has to exist on your nas and your nextcloud server. with the same id.

Not sure, I enabled NFS4.1 support, but don’t know if it’s connected with nfs3 or nfs4?

With “the user”, you mean www-data ?

Hi Kosta88,
is your NC running on a different server?? I have moved my NC folders from my NC installation to my NAS many times before. However, I need more information about your Setup and what really you are trying to achive. If i cannot help then i am sure others would try to help and then they know your situation

Many greetings

OK, sorry, I totally missed to explain that.
I have a Synology 1813+ NAS, which isn’t anything else but storage (no apps).
An ESXi server, Ubuntu Server 20.10 VM, with Nextcloud installation according to the tutorial here:
Install NextCloud on Ubuntu 20.04 with Apache (LAMP Stack) - LinuxBabe
Connection-wise I have OPNsense with haproxy in place, so Nextcloud is running on custom port, HTTPS, with self-signed certificate, and haproxy is delivering the real signed certificate.

So what I did, after getting Nextcloud to work with default data directory:
sudo-mounted shared-folder-on-nas to /mnt/nas
created nextcloud-data dir there
copied the files with -R
copied the .ocdata
set chown for www-data:www-data for /mnt/nas/nextcloud-data with -R
edited config.php file to set /mnt/nas/nextcloud-data

And this is where I get the error about missing .ocdata.

That’s about it.

However, I am annoyed by one thing which I can’t figure out, since I am fairly new to linux. I would usually mount the NAS to the /mnt/nas, and be able to browse it as a normal user (my user).
And I just checked it, on another server, I can. And it also worked the first time on the Nextcloud server. But not 2nd time around.
I can’t mount it without sudo, which is I believe fine.
But I cannot access it, except if I do sudo -i.
Nextcloud however, never worked. So, not sure what’s at fault here.

So, I am at the next step. A little bit ignorance on my side, I saw that I (back then for testing purposes, but then forgot about it), did a squash all to admin. Not such a good idea, so I am doing it right this time around. I created the www-data user on the Synology, and then tried to do groupmod and usermod. Those commands don’t exist. Neither does adduser.
So right now, I am again stuck…

I managed to create the www-data user and group on the Synology via SSH.
Now I have according to id www-data same user on both systems, all are UID and GID 33, same as www-data group which is 33 too.
I gave the folder on the nas rw permission for www-data user.

Yet I get this:
Your data directory is invalid
Ensure there is a file called “.ocdata” in the root of the data directory.
Your data directory is not writable
Permissions can usually be fixed by giving the webserver write access to the root directory. See

Data dir is here.
.ocdata exists

I can set chmod from Nextcloud, yet that doesn’t solve the problem.


Hoooly sh…t…
OK, permission issue. I had only owner rw, but I had to set 0770, found that somewhere… working now!

Baaah… still issues!

Now Sync is completely broken.
First I can’t delete anything via Website.
2nd, on computer, it say something about Sabre Exception Forbidden…
It says synced, but it’s not.

In Overview it tells me I still have a problem with .ocdata (missing).
However, it’s there, and same permissions as in the original folder:

Where do I troubleshoot?

After 3 hours of troubleshooting, I solved that too by going into DB, removing locks, and finally doing some commands I found around:
sudo -u www-data php occ files:scan --all
sudo -u www-data php occ files:cleanup

Maybe it helps someone.

For what it’s worth I just did this myself a few weeks ago.

I did a short write up on the process - Tutorial: NC VM Data Directory NFS Integration

I’m using Hansson’s vm as a template/starting point. Rather than doing it all from scratch I chose this because it has a number of system optimizations in it. Also, I was previously running an older version of this vm for a number of years with good results.

The nfs share is defined as follows on truenas 12.

dataset definition

can you paste your /etc/fstab configuration for the NFS share and other relevant settings?
I’m trying to configure Data folder on my Synology, and my Nextcloud is on docker on other server…no success until now.
thank you

$ cat /etc/fstab
# /etc/fstab: static file system information.
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/ubuntu-vg/ubuntu-lv during curtin installation
/dev/disk/by-id/dm-uuid-LVM-l9GWQy72N1EmFwPMVgTW34ckinREqysoTXFGtrlHSaErZXMAnUUQWbcJ84jsJPeU / ext4 defaults 0 0
# /boot was on /dev/sda2 during curtin installation
/dev/disk/by-uuid/35ae78d4-bad8-47e2-9ce2x-5a321feb0580 /boot ext4 defaults 0 0
/swap.img       none    swap    sw      0       0

#mount nfs for /mnt/ncdata /mnt/ncdata  nfs4 defaults         0     0
1 Like