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.

Emerge
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.

Linux
Verify if NFS version 4 is enabled in currently running Linux kernel.Tthis has to be ensured on the server as well as on the client installations:

Optionally NFSv4 support could be build as a kernel module. After NFSv4 support has been enabled a new Linux kernel must be built and installed in order to access the features. Restart the system after installing the Kernel.

A virtual NFS root directory needs to be created:

Create two sub-directories in the directory for NFS shares. This can be done in one fell swoop from the command-line by using the && operator:

NFS shares
Mount the shares to their mount points:

Add following two lines to fstab, so NFS shares will still be available after a system reboot:

NFS shares are configured in file. This file has following structure:

source1        target1(option1,option2) source2        target2(option1,option3)


 * source : is a directory the virtual root itself or particular nfs exported share f.e..
 * target : single host f.e. larrysPC, or a network 192.168.0.0/28, or a wildcard like f.e. * which means here it can be accessed from all networks by all hosts on all interfaces.

For options consult following table:

Specify the virtual root as the first entry, then define specific shares, in this particular case the file will look like in the example below:

To provide NFSv4 protocol access only, specify which version of the NFS protocol the server has to use -V 4 and which versions are not supported -N 3 -N 2 in the  file.

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 remote directories
Before mounting remote directories, a few daemons must be be started first. This is the job of the nfsclient service.

The directories can then be mounted with following command:

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 network 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