I have spent the week struggling to get an NFS mount to work between two machines, Server and Client, on a local network.
On Server (Ubuntu 24.04), I added the export command
/srv/data {Client IP}(rw,sync,fsid=0,root_squash,all_squash,anonuid=114,anongid=153,no_subtree_check,crossmnt)
to /etc/exports and enabled the export with $ sudo exportfs -ra.
I updated the firewall to allow connections from Client on port 2049.
$ sudo ufw status numbered
Status: active
To Action From
-- ------ ----
[ 1] 22 ALLOW IN {Client IP}
[ 2] 2049 ALLOW IN {Client IP}
I have verified that Server supports NFSv4:
$ sudo cat /proc/fs/nfsd/versions
+3 +4 +4.1 +4.2
During the long troubleshooting process I'm summarizing, I also edited /etc/nfs.conf on Server (that's the NFS config file Ubuntu 24.04) to log everything.
[mountd]
# debug="all|auth|call|general|parse"
debug="all"
I had also previously found during the troubleshooting process that I could sometimes mount the filesystem if the firewall were disabled on Server, so I've disabled it using sudo ufw disable during the tests I describe below. I restarted the server (sudo systemctl restart nfs-server.service) and re-export (sudo exportfs -ra) before testing, just to be safe.
On Client (Ubuntu 22.04), I added the line
{Server IP}:/srv/data /home/user/data nfs rw,nfsvers=4 0 0
to /etc/fstab and confirmed that Client supports NFSv4 the best way I can figure out how:
$ nfsstat -c | grep nfs
Client nfs v3:
Client nfs v4:
I try to activate the mount with
$ sudo mount /home/user/data
This fails with a "No such file or directory" error, and I confirm there is no mounted data.
$ sudo mount /home/user/data
mount.nfs: mounting {Server IP}:/srv/data failed, reason given by server: No such file or directory
$ ls /home/user/data | head -5
total 0
I check the logs on Server with journalctl -u nfs-mountd.
It appears to say access was granted:
Jun 20 16:54:14 Server rpc.mountd[29075]: auth_unix_ip: inbuf 'nfsd {Client IP}'
Jun 20 16:54:14 Server rpc.mountd[29075]: successful authentication for IP {Client IP} as {Client IP}
Jun 20 16:54:14 Server rpc.mountd[29075]: auth_unix_ip: client 0x5eda12751a40 '{Client IP}'
Jun 20 16:54:14 Server rpc.mountd[29075]: nfsd_fh: inbuf '{Client IP} 1 \x00000000'
Jun 20 16:54:14 Server rpc.mountd[29075]: nfsd_fh: found 0x5eda12757f70 path /srv/data
Jun 20 16:54:14 Server rpc.mountd[29075]: nfsd_export: inbuf '{Client IP} /srv/data'
Jun 20 16:54:14 Server rpc.mountd[29075]: granted access to /srv/data for {Client IP}
Jun 20 16:54:14 Server rpc.mountd[29075]: nfsd_export: found 0x5eda12757f60 path /srv/data
I don't know what to make of this or what to do next. The filesystem was not mounted on Client.
To add to the confusion, the mount would sometimes work completely randomly during the extensive troubleshooting process of the past week. Most of the time, I could take down the firewall on Server and then Client would mount the filesystem. Later, I'd come back to work on the problem again and, having changed nothing, Client would not mount the filesystem even with the firewall back down on Server. Even more bizarrely, I discovered that I frequently get the "mounting failed, No such file or directory error" even when Client successfully mounts the filesystem!
$ sudo mount /home/user/data
mount.nfs: mounting {Server IP}:/srv/data failed, reason given by server: No such file or directory
$ ls /home/user/data | head -5
total 774K
file1
file2
file3
...
(list of files that only exist on Server)
I have no idea what this implies, but I'm posting it in case it signals something. It does imply that since the mount can work, the fundamental aspects of this NFS share can't be too wrong.
This problem is similar to this one. Unfortunately, I can't make any of the answers there apply. In particular, I can confirm that both /etc/hosts.allow and /etc/hosts.deny on Server contain no uncommented lines, so it's not interference from that.
What do I do to further troubleshoot this issue?