How to configure permissions for linux NFSv4 client with Synology NAS?
I have an established Linux server (Ubuntu 12.04) and a new Synology NAS and am having trouble getting correct NFS user permissions on the mountpoint.
The server also mounts an NFS export from another Ubuntu server without issues, but the UIDs on that NFS server and the client are the same (ranging from 1001 to 1015). In the case of the Synology, UIDs start at 1024.
The following line from /etc/fstab
is how Synology and other examples show to configure the mount.
nas:/volume1/Video /mnt/nas/Video nfs nouser,rsize=8192,wsize=8192,atime,auto,rw,dev,exec,suid 0 0
I have configured idmapd.conf
as follows:
[General]
Verbosity = 0
Pipefs-Directory = /run/rpc_pipefs
# set your own domain here, if id differs from FQDN minus hostname
Domain = SYNOLOGY
[Mapping]
Nobody-User = nobody
Nobody-Group = nogroup
[Static]
homenas@SYNOLOGY = homenas
At this point when I mount the folder, everything looks correct until I create a file. The file is owned by nobody.nogroup, but I'm still able to make changes to it.
$ id
uid=1002(homenas) gid=1002(homenas) groups=1002(homenas)
$ pwd
/mnt/nas/Video
$ ls -l test
ls: cannot access test: No such file or directory
$ touch test
$ ls -l test
-rw-rw-r-- 1 nobody nogroup 0 Dec 24 15:30 test
$ rm test
How do I correctly mount an NFS share and retain the correct user permissions when the UIDs do not match, and enforce those permissions?
Solution 1:
Add nfsvers=3
to /etc/fstab
.
nas:/volume1/Video /mnt/nas/Video nfs nfsvers=3,nouser,rsize=8192,wsize=8192,atime,auto,rw,dev,exec,suid 0 0
The problem only occurs with NFS version 4, if you specify that you want NFS version 3, that solves the problem.