Can't create or write into the data directory stored on nfs share

Hello,
I read tons of forums/reddit/github about this problem, i spent weeks but no solutions yet.
I’m trying to install Nextcloud on small server and pointing /data folder on NFS (synology).
I create folder on synology, created www-data user and edited /etc/passwd and /etc/group to get id 33. Mounted NFS share and I tried with no squash and with root->admin too.

I tried to edit some configuration files:
- i # all lines “Check if there is a writable install folder.” and “Check if config folder is
writable.” inside the following files:
/usr/src/nextcloud/lib/private/legacy/OC_Util.php
/var/www/html/lib/private/legacy/OC_Util.php

My stack is:

> `version: "2"
> services:
> nextcloud:
> image: nextcloud
> container_name: nextcloud
> environment:
> - PUID=${PUID}
> - PGID=${PGID}
> - TZ=${TZ}
> - NEXTCLOUD_DATA_DIR=/data
> volumes:
> - /home/**************/Docker/Nextcloud/Config:/var/www/html
> - nfs-data:/data
> ports:
> - 444:443
> - 4488:80
> restart: unless-stopped
> depends_on:
> - nextcloud_db
> 
> nextcloud_db:
> image: linuxserver/mariadb
> container_name: nextcloud_db
> environment:
> - PUID=${PUID}
> - PGID=${PGID}
> - MYSQL_ROOT_PASSWORD=************
> - TZ=${TZ}
> - MYSQL_DATABASE=nextcloud_db
> - MYSQL_USER=nextcloud
> - MYSQL_PASSWORD=**************
> volumes:
> - /home/*********/Docker/Nextcloud/mariadb:/config
> restart: unless-stopped
> 
> volumes:
> nfs-data:
> driver_opts:
> type: nfs4
> o: addr=192.168.111.50,nfsvers=4,rw`

From container I can surf and write files inside /data folder:

root@df1e02d24e66:/# ls -lha
drwxrwx— 4 www-data www-data 4.0K May 8 09:35 data

If i change 777 on synolgy side installation start but then i get warning about 777 permission.

Any help???

I am having the exact same issue with almost the exact same setup. Hoping for a reply.

1 Like

I installed it quite some time ago but I recall data folder needs 655 (docker install on Ubuntu VM with data folder on NFS v3 mounted from TrueNAS).

Same for me sadly… In my case I’m trying to set up Nextcloud AIO. i can perfectly write and read inside my nfs mounted /mnt/ncdata folder using www-data as user (with the command sudo -u www-data mkdir test) but when the config starts it says that nextcloud cannot create or write inside /mnt/ncdata. I really do not understand what to do here. By the way, I gave www-data:www-data permissions, as well as 775 on the /mnt/ncdata folder, but also on the corresponding folder in my Synology. Any idea? :slight_smile:

@EgonHeuson
First check you have configured all correctly e.g. in /etc/fastab. Read e.g. this.

Then check this:

sudo - u www-data touch /mnt/ncdata/testfile
sudo -u www-data touch /mnt/ncdata/test/testfile

Only if it works you can check it with your Nextcloud.
Also post more details of your settings.

Thank you for your answer!
So, I tested the 3 following commands as requested, and all were perfectly fine:

sudo -u www-data touch /mnt/ncdata/testfile
sudo -u www-data mkdir /mnt/ncdata/test/
sudo -u www-data touch /mnt/ncdata/test/testfile

By the way, obviously if I try to run sudo -u www-data touch /mnt/ncdata/test/testfile without having created the /mnt/ncdata/test folder first I get an error obviously.

So everything seems to be working fine on the nfs side

I have also read up on how to mount the nfs, especially in the article you recommended. Here is the configuration in my fstab:

192.168.X.X:/volume1/Nextcloud /mnt/ncdata nfs x-systemd.automount 0 0

I replaced “defaults” with “x-systemd.automount” because without it the nfs drive does not mount itself at boot time. However, I checked that it was well mounted with df -h before launching the Nextcloud installation.

That’s why I don’t understand…

[EDIT]: I think I’ve found the solution but it is extremely weird. It was this post that gave me the indication: Post #71477
If I create a sub-folder /mnt/ncdata/data and then use this one (and not the root of the nfs drive /mnt/ncdata/) as a folder for Nextcloud files by passing

NEXTCLOUD_DATADIR=/mnt/ncdata/data

in “environment”, there are no more problems with the Nextcloud installation… It’s hard to understand. but at least it seems to work. What do you think?

It is really hard to unterstand. Maybe the “owner” because of the “mountpoint” is root and not www-data.

Maybe :frowning: Really confused here…

hey,
can you share your config? do you have stack/docker-compose file?

no solution found yet, just crazy

Did you figured out the problem? I’m also stuck on this!

Hello! Sorry for the delay, I had no time before. I managed to have everything working with NextcloudAIO, but the procedure should be almost the same for you. Here are the steps I used:

First install Docker and docker-compose

Then:
Create a Nextcloud shared folder in your Synology NAS, and give the access to your Nextcloud machine using the following parameters (sorry in French):

2022-11-17_10-25-53

Go back on the Nextcloud machine and install the required packages for nfs
$ apt install nfs-common -y

Create a mount point
$ mkdir -p /mnt/nextcloud

Mount the remote NFS drive to the mount point
$ mount X.X.X.X:/NASVolumeNumber/Nextcloud /mnt/nextcloud #X.X.X.X is the IP of your NAS

Check the NFS version that is used for mounting the drive
$ mount -v | grep /mnt/nextcloud

Check that everything is correctly mounted
$ df -h

Make the mounting process activated at boot
$ nano /etc/fstab

Add:

X.X.X.X:/NASVolumeNumber/Nextcloud /mnt/nextcloud nfs x-systemd.automount 0 0 #x-systemd.automount is used to automount via systemd

Save the file

Mount all
$ mount -a

Create nextcloud data and backup directories

$ mkdir /mnt/nextcloud/ncdata
$ mkdir /mnt/nextcloud/ncbackup

Change owner for mount point in client
$ chown -R www-data:www-data /mnt/nextcloud

Change permission rules on the mount point in the client
$ chmod 755 -R /mnt/nextcloud

Optional if the permissions on the Synology where not changed with the previous commands
Connect to the Synology Server and change user and group to the mounted folder according to client’s user ID

$ sudo chgrp -R +33 /NASVolumeNumber/Nextcloud
$ sudo chown -R +33 /NASVolumeNumber/Nextcloud

Install Nextcloud AIO using docker-compose
As Root!

$ mkdir -p /home/user/Nextcloud
$ cd /home/user/Nextcloud/
$ nano docker-compose.yml

Paste

###################################################
version: "3.8"

volumes:
  nextcloud_aio_mastercontainer:
    name: nextcloud_aio_mastercontainer
services:
  nextcloud:
    image: nextcloud/all-in-one:latest
    restart: unless-stopped
    container_name: nextcloud-aio-mastercontainer
    volumes:
      - nextcloud_aio_mastercontainer:/mnt/docker-aio-config
      - /var/run/docker.sock:/var/run/docker.sock:ro
    ports:
      - 8080:8080
    environment:
      - APACHE_PORT=11000
      - APACHE_DISABLE_REWRITE_IP=1
      - NEXTCLOUD_TRUSTED_DOMAINS=xxx.xxx.com X.X.X.X # Your domain name + proxy host IP if using a reverse proxy
      - TRUSTED_PROXIES=X.X.X.X # proxy host IP if using a reverse proxy
      - NEXTCLOUD_DATADIR=/mnt/nextcloud/ncdata
      - NEXTCLOUD_MOUNT=/mnt/
###################################################

Save

Then run the docker-compose command
$ docker compose up -d

You should be good to go :smiley: