Nfs-utils

Network File System (NFS) is a file system protocol that allows client machines to connect to network attached file shares. The newest version is version 4.

Software
Install :

Configuration
The NFSv4 server configuration is mostly like configuring the version 3, with one major change all NFS shares are exported from one virtual root directory.

The server has 2 NFS shares which are:


 * - directory with user homes
 * - directory with example data

These 2 shares are mounted on the server system at following points in the tree:

The client uses now TCP protocol as default, to mount NFS shares. Previous NFS versions use UDP as the default protocol.

Kernel
NFS server support is not required for NFS clients, and NFS client support is not required for NFS servers. Dnotify support is only required for NFSv4. NFSv3 is only required for compatibility with legacy clients e.g. the BusyBox mount command does not support NFSv4.

Virtual root
The filesystems to be exported must be made available under a single directory. This directory is known as the virtual root directory, and it is required for NFSv4.

Create directories in the virtual root directory for the filesystems (e.g and ) that are to be exported:

The filesystems to be exported need to be made available under their respective directories in the virtual root directory. This is accomplished with the   option of the  command:

To make the above mounts persistent, add the following to :

Exports
The filesystems to be made accessible for clients are specified in. This file consists of the directories to be exported, the clients allowed to access those directories, and a list options for each client. Refer to man exports for more information about the NFS export configuration options.

The above configuration grants access to the exported directories by IP network, in this case. Client access can also be specified as a single host (IP address or fully qualified domain name), NIS netgroup, or with a single  character which grants all clients access.

The following table briefly describes the client options used in the configuration above.

Daemon
The NFS daemon is configured via.

The option  is the number of NFS server threads to start. Since only one thread is started by default, the thread count should be increased for optimal performance. The options  and   disable NFS versions 2 and 4.2, while options ,   and   enable NFS versions 3,4 and 4.1. Refer to man nfsd for more information about the NFS daemon configuration options.

Starting service daemon
Finally start the configured NFS daemon:

As shown many services are started in specific order, rpcbind is started as the first service. If there is a need to stop the NFS service, the easiest way to stop all NFS services at once is to stop the rpcbind service itself.

It command will shutdown each service shown in the upper starting routine example:

Add the nfs script to a runlevel to be able to use it after a reboot:

Mounting exported directories
The NFS client needs to be started before exported directories can be mounted.

Mount an exported directory:

If the NFS server or client supports NFSv3 only, the full path to the exported directory (e.g. ) must be specified when mounting:

Mounting at boot time
Add NFS shares to the file.

Option 1
Mount the NFS virtual root including all exported shares at once.

Option 2
Define each NFS share individually, to have the ability to mount them to different local mount point:

Finally start the netmount service:

Add nfsclient and netmount services to the default runlevel:

At this point the NFS shares should be mounted on the client. It can be verified with following command:

Or run:

Shutdown process hangs when trying to unmount NFS shares
If the system shutdown hangs at then users must make sure the NFS shares are unmounted properly before udev tries to stop. One way to work around this is to create local.d scripts to unmount the NFS filesystems:

Additional troubleshooting tricks and tips
Verifying NFS server is running and listening for connections:

Verifying which NFS specific daemons are running:

Showing exported NFS shares on the server side:

Verifying current open connections to the NFS server:

For more specific troubleshooting examples visit following links:


 * http://linux-nfs.org/wiki/index.php/General_troubleshooting_recommendations
 * http://nfs.sourceforge.net/nfs-howto/ar01s07.html

External resources

 * RFC 3530
 * Ubuntu Community Wiki NFSv4 article
 * Gentoo Community Wiki article article