LinkedIn Sourceforge

Vincent's Blog

Pleasure in the job puts perfection in the work (Aristote)

Best practices for NFS on OpenBSD

Posted on 2016-08-22 19:41:00 from Vincent in OpenBSD Nas

Let me share my expertise for the best parameters of NFS client on a laptop running OpenBSD.


I'm writing this small article because this is the one I was looking for on internet related to NFS client on OpenBSD's laptops. Indeed, after having read, re-read, re-re-read the man pages for NFS, I was disappointed to see that NFS can hangs some of my desktop's applications.

By searching on Google, I can find lot of people annoyed with some NFS hangs, but I've never read a real solution that allow me to umount my NFS filesystem on my OpenBSD laptop.

First of all, let me share with you some contextual elements:

  • the server is running NFS (on OpenBSD 5.9 in my case)

  • the client machine is a laptop running OpenBSD 5.9.

  • The network can be via an ethernet cable or via wifi.

As someone else already said, one of the beauty of OpenBSD is his stability. On laptop too.
So, I'm used to boot my laptop and let it runs for weeks and months before rebooting it.
Between each use, I just close the lid and it goes immediately in hibernate mode.

The drawback of this is coming from the portability of a laptop. Indeed, for example, you close it in your house's network, and you re-open it somewhere else with a different network connection. In such case this cause NFS troubles.
With the default parameters, the NFS mount (on your laptop) remains open, even if the connection to the NFS server is lost. Thus GUI application you'll use will wait to see the mounted folder's content. Since NFS cannot reach your NFS server, the GUI application will wait for a very long time. And you are blocked :(.


To avoid this situation, we must umount the NFS file system.

So I share with you couple of parameters that will help to umount the NFS mounted file system very quickly:

t420:~$ grep nfs /etc/fstab   
nas:/mnt/sd1 /net/nas nfs  rw,noauto,nodev,nosuid,soft,intr,-T,-x=2 0 0

Some explanations:

  • "rw", "nodev", "nosuid" : those parameters will not help us for this purpose. They are quite usual. I refer you to the man pages to better know them.

  • "noauto" : This avoid an automatic mount at each reboot. This is important because, with a laptop, you could reboot your machine outside of your usual network; where the NFS server is not reachable.

  • "soft" : the file system mount will fail after certain delay.

  • "intr" : informs NFS that the mount is interruptible.

  • "-T" : Force TCP. I've discovered that having the mount in TCP facilitate the closure of the mounted sessions.

  • "-x=2" : set to 2 the retransmit timeout count for soft mounts

Conclusion

Side to the "soft" and "intr" parameters, it's useful to force TCP and reduce the "retransmit" to a lower value.



33, 33
displayed: 7032



What is the first vowel of the word Moon?