NFS Mount Options For Part-Time Servers

A lot of posts on this blog are more in the way of tips and howtos, short articles that explain how to get things done in Linux. Here’s another one and the subject today is to explain how to configure NFS to work with “part time” servers. By this I mean a computer that is (a) not an actual dedicated server and therefore (b) not actually turned on all the time. I have several computers and one of the key functions is to share file storage capacity between them. As such, they are acting as file servers in this role. However there are times when not all of them will be running, and in those times, NFS can be frustrating when every application that is running in the system spends its time looking for those systems that are offline and cause applications to freeze/hang.

Persistent NFS mounts, like all mounts, can be put into the /etc/fstab (file system table) file for convenience, regardless of whether they should be auto mounted at boot time or manually mounted at some random time when a user needs them. This post lists the third way of doing things that falls between automatic and manual mounting, which is to have Linux decide during the boot process if the mount can be completed and skip if it doesn’t. The two options I am going to mention in this post which make that useful are soft and bg. soft is one of a pair of options, the other being hard, that specify what happens when a client’s NFS request times out. The default, hard, causes infinite retries, whereas soft specifies that the request will fail after a certain number of retries. This number can be specified with another option, the default being 3.

The second useful option in this context is bg, which means background and is paired with fg (foreground), the latter being the default. These refer to how the NFS client process handles mounts at boot time. The foreground option causes the boot process to pause until the mount is completed, whilst background causes it to fork a separate process to complete the request. Since the default timeout for completing a mount is two minutes, it can be seen that the foreground option results in undesirable startup delays when a server may be offline. The default timeout for a background request is one WEEK, which implies that it will automount if a server comes online later by itself, also a desirable behaviour not provided in the foreground option with its eventual two minute timeout.

When many of these posts are made, they are tagged “InstallMyPC”, which is a useful tag I put onto many posts to remind me what to set up again after reinstallation. This post certainly qualiifies because setting up the mounts in the /etc/fstab file is one of the steps that has to be redone each time as this file is part of the system profile rather than a user profile and has to be created from scratch in a new installation.

Testing with soft,bg as nfs mount options has proved to worthwhile on all my computers and therefore is now part of the normal settings for setting up nfs mounts.