Solaris Troubleshooting : NFS – Hard vs Soft mounts
NFS-filesystems that are mounted read-write or that contain executable files should always be mounted with the “hard” option.
Normally an application is not aware of where the data (files) it is accessing is located – it only knows the pathname. The data could be located locally in an UFS or VxFS or <whatever> filesystem, or it could be located on an NFS filesystem. The application doesn’t care where the data is located (that’s the kernel’s job) and accesses the data by standard C-function calls such as open(), read(), write(), close(), etc.
Generally, the “normal” application usually only handles those return-codes of the file-accessing function calls it expects to receive.If an NFS client has problems in communicating to a NFS server (e.g. if the server’s responses are dropped on the network), we’ll see a different behaviour between the mount options “hard” and “soft”.
When the client has used “hard” (the default) when mounting, the NFS-module that is loaded in the client’s kernel takes care of all network-related NFS errors. It will perform/initiate all the required retry, retransmit, etc. operations before it hands over a return-code to the application program that a “normal” application usually expects.
When the client has used “soft” when mounting, the kernel-loaded NFS module will immediately forward any return code back to the calling application. Then the application itself will have to handle such return codes; which it perhaps doesn’t expect to see. Many applications aren’t implemented to handle such NFS-specific return codes.
That’s why the mount option “soft” should:
– only be used for read-only NFS access to data.
– and never be used for read-write NFS access and/or read-onlyNFS-access on executable programs.
The Actual mount_nfs man page says:
Hard versus Soft File systems that are mounted read-write or that contain executable files should always be mounted with the hard option. Applications using soft mounted file systems may incur unexpected I/O errors, file corruption, and unexpected program core dumps. The soft option is not recommended.