Nfs-utils

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

Emerge
Install :

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.

Server
The following table describes the filesystems that will be exported by the server:

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

If changes are made to after the NFS server has started, issue the following command to propagate the changes to clients:

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 option  disables NFS version 2, while options ,   and   enable NFS versions 3,4 and 4.1. Refer to for more information about the NFS daemon configuration options.

Service
OpenRC

To start the NFS server:

The above output shows that many other services are also started along with the service. To stop all NFS services, stop the service:

To start the NFS server at boot:

Service
OpenRC

To be able to mount exported directories, start the NFS client:

To start the NFS client at boot:

Mounting exports
Mount the exported directories:

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

The virtual root directory can be mounted instead of each individual exported directory. This will make all exported directories available to the client:

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

When using to mount the exported directories, add the  service to the default runlevel:

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

The same applies when mounting the virtual root directory:

Troubleshooting

 * The system may become unresponsive during shutdown when the NFS client attempts to unmount exported directories after udev has stopped. To prevent this issue, a local.d script can be used to forcibly unmount the exported directories during shutdown:


 * Verify that the NFS server is running and listening for connections:


 * Verify which NFS daemons are running:


 * List the exported directories from the NFS server:


 * List the current open connections to the NFS server:


 * Verify that the exported directories are mounted by the NFS client:

External resources

 * RFC 3530 - Network File System (NFS) version 4 Protocol
 * Ubuntu Wiki - NFSv4Howto
 * Funtoo Wiki - NFS
 * Gentoo Wiki Archives - HOWTO NFSv4
 * Linux NFS - General troubleshooting recommendations
 * Linux NFS - HOWTO Troubleshooting