Forcibly Unmounting NFS Filesystems

forcibly unmounting nfs filesystems
preventative steps
12
use the “soft” NFS
mount option
By default, NFS filesystems are mounted with the “hard” option, which instructs the
client’s kernel to indefinitely retransmit any NFS request that is not responded to by the
NFS server. In other words, if a process on an NFS client attempts to access a file on an
NFS server that is down or otherwise unresponsive, the client will continue to resend NFS
requests to the server until that system (or a different system masquerading as the server)
3
responds. This behavior is intentional and designed to guarantee data integrity.
While there are definite benefits to this “hard” mount behavior, there are also drawbacks
– especially in environments where NFS servers are frequently unavailable. In these
environments it may be preferable to allow NFS clients to eventually “give up” when
trying to communicate with a down server and return control to the requesting
applications. This can be done by mounting the NFS filesystems using the “soft” option.
In the previous example on pages 7 through 10, the NFS filesystem was mounted with
the default “hard” option, forcing the client to continually resend NFS requests to the
server until it received a response. If a “surrogate” server had not been configured, or
the original NFS server not been restored to service, any client applications accessing this
filesystem would hang indefinitely.
In Figure 4 below the same exercise is repeated, except in this case the NFS filesystem is
mounted with the “soft” option. When the NFS server crashes (in step 3) the client’s
kernel will attempt to communicate with the server by retransmitting the NFS requests that
have not been responded to. However, the “soft” option instructs the client to eventually
give up and return an I/O error to the dd(1) process. Once all of the processes
accessing this hung NFS filesystem exit the filesystem can be successfully unmounted.
Figure 4 – Writing to a down NFS server via a “soft” mounted filesystem
3
Refer to the example shown on pages 7 through 10.