Nfs-utils

Network File System (NFS) is Article description::a file system protocol that allows client machines to access network attached filesystems.

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.

Emerge
Install :

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

Virtual root
The filesystems to be exported can be made available under a single directory. This directory is known as the virtual root directory:

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:

Multiple IP addresses
To add extra interfaces or IP addresses to the shares already configured, add the them to the corresponding line in. Below is a sample configuration using a local IPV6 address.

Different client options can be defined for each each IP address/interface.

OpenRC
The NFS daemon on OpenRC is configured via the OPTS_RPC_NFSD variable:

systemd
The NFS daemon on systemd is configured via the RPCNFSDARGS variable:

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:

systemd

To start the NFS server:

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:

systemd

The service will be started automatically when systemd detects that exported directories are being mounted.

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:

When mounting exported directories on an IPv6 network, enclose the IPv6 NFS server address in square brackets:

When mounting a link-local IPv6 address, the network interface must also be specified:

With NFSv4, the virtual root directory is rather 'invisible'; use relative path:

Kerberos
It is possible to identify NFS client using Kerberos GSS. This will require a few modifications. In the following instruction, it is supposed that Kerberos is already installed on the same server as NFS (which hostname is server.domain.tld) and that the client (client.domain.tld) is able to to it. The Kerberos default realm it DOMAIN_REALM.TLD.

First, enable the following kernel option for both server and client. Note that this option may not appear if all cryptographic dependencies are not selected. See kernel option dependencies for more information:

Then, create principals for the NFS service for both the server and the client. On the server, execute:

Each computer must have its password saved in a local keytab. The easiest way to do it is (on the server):

and then transfert the to the client, with the name. Note that the file should be owned by root with 0600 mode.

The service must run at client side. The following line must appear in of the client:

The services and  must run at server side. The following line must appear in of the server:

The service must be correctly configured (on the server):

Add  to the export options.

It is also possible to increase security with  (user authentication and integrity checking) or even   (user authentication, integrity checking and NFS traffic encryption). The more security, the more resources are needed.

The same option must be added to the mount command at client side.

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 7530 - Network File System (NFS) version 4 Protocol
 * Ubuntu Wiki - NFSv4Howto
 * Funtoo Wiki - NFS
 * Linux NFS - General troubleshooting recommendations
 * Linux NFS - HOWTO Troubleshooting