I have a problem getting files to show up using an NFSv4 mount between
Server: Ubuntu 20.04, 192.168.1.1
Client: Ubuntu 18.04, 192.168.1.2
On the server, I have a folder and file
/home/server/files/myfile.pdf
(note 'server' is being used as the user account name). Here is the full ownership and permissions chain of the original file:
drwxr-xr-x root:root /
drwxr-xr-x root:root /home/
drwxr-xr-x server:server /home/server/
drwxrwxr-x server:nfsgroup /home/server/files/
-rwxrwxrwx server:nfsgroup /home/server/files/myfile.pdf
Here you can see an example of a utility 'user':'group' I created:
nfsuser uid=127
nfsgroup gid=134
Both 'nfsuser' and 'server' are in the 'nfsgroup' group.
On the server, I have the /files/
directory bind-mounted to /srv/nfs4/files/
in /etc/fstab
, with an entry
/home/server/files /srv/nfs4/files none bind 0 0
This is successful, and I can clearly see the /srv/nfs4/files/myfile.pdf
file as
-rwxrwxrwx server:nfsgroup /srv/nfs4/files/myfile.pdf
Here is the full ownership and permissions chain of the mounted and served file:
drwxr-xr-x root:root /
drwxr-xr-x root:root /srv/
drwxrwxr-x server:nfsgroup /srv/nfs4/
drwxrwxr-x server:nfsgroup /srv/nfs4/files/
-rwxrwxrwx server:nfsgroup /srv/nfs4/files/myfile.pdf
Now, I want to export the entire /srv/nfs4/
directory, which contains the bind-mounted files/
, to the client. I have this entry in the server's /etc/exports
:
/srv/nfs4 192.168.1.2(rw,sync,fsid=0,root_squash,all_squash,anonuid=127,anongid=134,no_subtree_check)
Note in particular that the all_squash,anonuid=127,anongid=134
group of settings causes the client user 'client' to be recognized as 'nfsuser' in the 'nfsgroup' with regards to permissions.
After I export this using $ sudo exportfs -ra
, I mount it to the root-level directory /nsffiles/
on the client using the command $ sudo mount -t nfs 192.168.1.1:/srv/nfs4 /nsffiles
.
The result is that I can see the exported files/
directory within /nsffiles/
on the client. However, I cannot see its contents:
$ ls -Alhd /nsffiles/
drwxrwxr-x 8 client 134 4.0K Nov 14 20:37 /nsffiles/
$ ls -Alhd /nsffiles/files/
drwxr-xr-x 2 root root 4.0K Nov 14 20:36 /nsffiles/files/
$ ls -Alh /nsffiles/files/
total 0
The fact that the NFS client can see the files/
directory at all indicates there's nothing fundamentally wrong with my NFS services or the local network. There's no firewall issues, and I shouldn't need to install any additional packages. Also, I previously had the NFS mount working perfectly under a slightly different folder structure (files/
was in a directory outside of home, for example), so I know the basics are fine in that regard.
I assume that the most likely cause of why it won't work now is a subtle ownership/permissions change between the previous setup and the current one. In particular, the mounted directory is
server side: `/srv/nfs4/` drwxrwxr-x server:nfsgroup
client side: `/nsffiles/` drwxrwxr-x client:134
The contained directory is
server side: `/srv/nfs4/files/` drwxrwxr-x server:nfsgroup
client side: `/nsffiles/files/` drwxr-xr-x root:root
That is, for the mounted directory, the permissions convert as server:nfsgroup -> client:134
, which is expected. The permissions for the contained directory, however, convert as server:nfsgroup -> root:root
. Why root:root
and not client:134
?
This ServerFault question sounds similar, but it concerns Windows, and I can't tell that the only answer applies.
This Unix.SE question concerns NFS file permissions for a Windows/Linux setup; all of the information I can glean from it is things I already know and think I've taken care of.
Please respond only if you know what you're talking about. If you can't resist posting a wild guess, please identify it as a wild guess. Or, you know, provide enough information that your reader can tell the difference.