NFS and VOV
Before you can use NFS, be it as server or client, you must make sure your kernel has NFS support compiled in.
NFS on Linux Only
Newer kernels have a simple interface on the proc filesystem for this, the
/proc/filesystems file, which you can display using
cat. If nfs
is missing from this list, you
have to compile your own kernel with NFS enabled, or perhaps you will need to load
the kernel module if your NFS support was compiled as a module.
NFS Mounting Options
/etc/fstab
entry
for the volume. In both cases, multiple options are separated by commas and must not
contain any whitespace characters. Options specified on the command line always
override those given in the fstab file.
The
following is a partial list of options you would probably want to use:- Option
- Description
rsize=n and wsize=n
- These specify the datagram size used by the NFS clients on read and write requests, respectively. The default depends on the version of kernel, but is normally 1,024 bytes.
timeo=n
- This sets the time (in tenths of a second) the NFS client will wait for a request to complete. The default value is 7 (0.7 seconds). What happens after a timeout depends on whether you use the hard or soft option.
retrans=n
- The number of minor timeouts and retransmissions that must occur before a major timeout occurs. The default is 3 timeouts. When a major timeout occurs, the file operation is either aborted or a "server not responding" message is printed on the console.
hard
- Explicitly mark this volume as hard-mounted. This is on by default. This option causes the server to report a message to the console when a major timeout occurs and continues trying indefinitely (The client will continue to attempt the NFS file operation indefinitely if the operation fails). Hard mounts should be used when the server and the link to the server are known to be reliable. Hard mounts with the interruptible option enabled is the recommended method of mounting remote filesystems.
soft
- Soft-mount (as opposed to hard-mount) the driver. This option causes an I/O error to be reported to the process attempting a file operation when a major timeout occurs (timeo option). Retries NFS file operation n times (retrans option) as set by the number of retries before reporting error option; returns error if no server response in n tries. Soft mounts are recommended for filesystems whose servers are considered unreliable, or if the link is slow. Unlike spongy mounts, soft mounts may time out during read and write operations.
spongy
- Sets soft semantics for stat, lookup, fsstat, readlink, and readdir NFS operations and hard semantics for all other NFS operations on the filesystem. Spongy mounts are preferable to soft mounts because spongy mounts will not time out during read and write operations. They are recommended for slow, long-distance, or unreliable links, and for unreliable servers.
intr
- Allow signals to interrupt an NFS call. Useful for aborting when the server doesn't respond.
Except for rsize
and wsize
, all of these options
apply to the client's behavior if the server should become temporarily inaccessible.
They work together in the following way: Whenever the client sends a request to the
NFS server, it expects the operation to have finished after a given interval
(specified in the timeout timeo
option). If no confirmation is
received within this time, a so-called minor timeout occurs, and the operation is
retried with the timeout interval doubled. After reaching a maximum timeout of 60
seconds, a major timeout occurs.
By default, a major timeout causes the client to print a message to the console and start all over again, this time with an initial timeout interval twice that of the previous cascade. Potentially, this may go on forever. Volumes that stubbornly retry an operation until the server becomes available again are called hard-mounted. The opposite variety, called soft-mounted, generate an I/O error for the calling process whenever a major timeout occurs. Because of the write-behind introduced by the buffer cache, this error condition is not propagated to the process itself before it calls the write function the next time, so a program can never be sure that a write operation to a soft-mounted volume has succeeded at all.
Whether you hard- or soft-mount a volume depends partly on taste but also on the type
of information you want to access from a volume. For example, if you mount your X
programs by NFS, you certainly would not want your X session to go berserk just
because someone brought the network to a grinding halt by firing up seven copies of
Doom at the same time or by pulling the Ethernet plug for a moment. By hard-mounting
the directory containing these programs, you make sure that your computer waits
until it is able to re-establish contact with your NFS server. On the other hand,
non-critical data such as NFS-mounted news partitions or FTP archives may also be
soft-mounted, so if the remote machine is temporarily unreachable or down, it
doesn't hang your session. If your network connection to the server is flaky or goes
through a loaded router, you may either increase the initial timeout using the
timeo
option or hard-mount the volumes. NFS volumes are
hard-mounted by default.
Hard mounts present a problem because, by default, the file operations are not
interruptible. Thus, if a process attempts, for example, a write to a remote server
and that server is unreachable, the user's application hangs and the user can't do
anything to abort the operation. If you use the intr
option in
conjunction with a hard mount, any signals received by the process interrupt the NFS
call so that users can still abort hanging file accesses and resume work (although
without saving the file).
Allows the user to kill a process that is hung while waiting for a response on a
hard-mounted filesystem. This option is useful if the server or the connection to
the server is known to be slow or unreliable. It is recommended to always have the
intr
option on. A keyboard interrupt is configured by entering
stty intr key
where key
is the keyboard key
you wish to use to issue an interrupt.
NFS that are mounted rw should use the hard
option (plus eventually
the intr
one).
Do not specify either soft
and intr
options when
mounting NFS filesystems that are writable or that contains executable files.