Issue with NFS share auto-remount after NFS server restart

Hi
Help me, please, with the following issue:
- there is NFS server (Windows 11, WinNFSd.exe as NFS server)
- there is NFS client (FreeBSD 15.0)
Issue: mounted share stops working on client if server was restarted.

First, I just added 10.0.0.3:/share /mnt/share nfs ro 0 0 to the /etc/fstab.
Everything works fine until I restart NFS server. After restarting the NFS server, I have to do umount-mount cycle to get access to that share again.
Also, I tried to add the following mount options: intr,nolockd,bgnow - didn't help.

Second, I tried to use autofs automounter:
- removed that NFS mount from the /etc/fstab
- added autofs_enable="YES" into /etc/rc.conf
- added /mnt/nfs /etc/auto.nfs into /etc/auto_master
- created /etc/auto.nfs with the following line: share -intr 10.0.0.3:/share
- created /mnt/nfs directory
- started automount service
And have almost the same issue: if I restart NFS server, no more access to that shared NFS resource. But in this case I get "Stale NFS file handle" error when attempt to open the shared NFS resource.
The same with the following mount options: intr,nolockd,bgnow - no changes.

Is there any way to have reconnection to the NFS server be made automatically?

Or any option to mount SMB v.3 share in FreeBSD?

Thanks
 
Not related to your issue, but don't use /mnt for anything 'permanent'. It's supposed to be a temporary mount point.

Code:
     /mnt/      empty directory commonly used by system administrators as a
                temporary mount point
hier(7)
 
The issue you are experiencing seems to be Windows 11 ( NFS) related.

I can not reproduce the problem on a FreeBSD 15 NFS server/client setup (I don't have a Windows installation to test). A NFSv3 ( or NFSv4 for the matter, which is not supported on Windows 11 IIRC) mounted share remains accessible while mounted after the FreeBSD NFS server is rebooted, without "intr" and "nolockd" mount options. E.g.:

NFSv3
Code:
mount  server:/share  /media/nfsshare
mount implies mount_nfs(8)

What does nfsstat -m on the FreeBSD client show?

Or any option to mount SMB v.3 share in FreeBSD?
FreeBSD supports only SMBv1 (mount_smbfs(8), see STANDARDS section).

For SMBv3 you need to install one of the 3rd party ports/packages:
Code:
% pkg search -r FreeBSD-ports samba4
samba416-4.16.11_10            Free SMB/CIFS and AD/DC server and client for Unix
samba419-4.19.9_12             Free SMB/CIFS and AD/DC server and client for Unix
samba420-4.20.8_1              Free SMB/CIFS and AD/DC server and client for Unix
samba422-4.22.7_1              Free SMB/CIFS and AD/DC server and client for Unix
samba423-4.23.6_1              Free SMB/CIFS and AD/DC server and client for Unix
 
The problem is that when the Windows NFS server restarts, the file handles your FreeBSD client holds become stale. The client has an open mount but the server has forgotten the export state. The mount hangs rather than automatically recovering because that is default NFSv3 hard mount behavior.

There are two clean approaches.

First option — soft mounts with background retry: add the `soft` and `bg` options to your fstab entry:

10.0.0.3:/share /media/nfsshare nfs soft,intr,bg,timeo=30,retrans=5,rsize=32768,wsize=32768 0 0

With `soft` the client gives up after the retry count and returns an error instead of hanging. With `bg` the initial mount is retried in the background if the server is unreachable. The downside is that writes may be silently lost on a server restart, so this is only appropriate for read-only mounts or where data loss is acceptable.

Second option — autofs done correctly: the autofs setup you started is the right approach for auto-recovering mounts. The typical configuration looks like this.

In /etc/auto_master:
/mnt/nfs /etc/auto.nfs --timeout=60

In /etc/auto.nfs:
share -fstype=nfs,soft,intr,timeo=30 10.0.0.3:/share

Then:

service automount start
service automountd start

The key difference with autofs is that the mount happens lazily when you first access /mnt/nfs/share, and it unmounts automatically after the timeout when idle. If the server is down when you access the path you get an error immediately rather than a hang. When the server comes back up, the next access auto-mounts it again. This is exactly the auto-recovery behavior you want.

One additional thing worth checking: WinNFSd has known issues with NFSv3 MOUNT protocol replies after restart. Run `showmount -e 10.0.0.3` from the FreeBSD client after the server restarts to verify the export is visible again before trying to remount. If showmount hangs, the issue is on the Windows side and you may need to restart WinNFSd completely, not just the export.
 
Back
Top