NFS/Server

Kernel Modules
You first need to enable kernel support for NFS. Use make menuconfig to enable the following options:

The majority of installations are using NFSv3, so NFSv4 support is optional. You should also note that NFSv4 support may not be included on older clients. If you opt to compile NFS server support as a module, it will be called nfsd.

Userspace Support
You'll need the userspace scripts that control the NFS service, so install them with:

Creating Shares
The list of directories that clients are allowed to mount is stored in.

In the above example, the directory can be mounted only by 192.168.0.3, while the  and  directories can be mounted by any machine on 192.168.*.*

The following are the most frequently used options that can be specified for each share. For a full list see the exports(5) man page.
 * rw - Allow read and write access
 * ro - Allow read only access - no write access
 * async - Reply to requests before data has been committed to the file system. This improves performance, but increases the risk of data loss in the event of a server crash.
 * no_subtree_check - Disable subtree checking. The technical details are in the man page, but essentially it's recommended for read/write filesystems where files change frequently, such as . If you disable subtree checking and export something that's not the root of a filesystem, it's possible a client could access a file outside the exported directory, however.
 * root_squash - Prevent the client creating files owned by root - instead they will be owned by the anonymous uid/gid (user id / group id, see man page for details).
 * no_root_squash - Turn off root squashing. Mostly used on diskless clients.
 * all_squash - Map all uids/gids to the anonymous user. This means that all files written to this filesystem will be owned by the same user.

Starting the Server
To start the nfs server, making the shares accessible to clients, run:

To have the server start automatically on boot, run:

Reloading Exported Shares
If you make changes while the NFS server is running, you'll need to reload the exports before the changes take effect using:

Forced binding to specific ports
For a firewall-friendly server configuration, you may want to force the rpc.statd, rpc.mountd, rpc.quotad and nlockd daemons to listen on specific ports.

For statd, mountd and rquotad, the settings can be adjusted in /etc/conf.d/nfs.

The newest kernels manage the lock system via a lockd module. Deduce whether or not you have NFS built in to the kernel (Y) or as a module (M).

If M:

If Y (and M if /etc/conf.d/modules didn't work):

For the previous kernels (lockd service), the port assignment can be set through sysctl.conf:

Troubleshooting
If your NFS service doesn't start and you have this error in logs: Log error take a look to.

If you get the error message "mount: RPC: Program not registered": Ensure that the portmapper service is running on both the server and the client machines and that /etc/hosts.allow has been setup to allow remote access. See the manpage for hosts.allow for more information.

You may experience poor performance with the default setting of RPCNFSDCOUNT under certain intensive workloads, such as running KDE 4 with NFS shared home directories. If you have problems with extremely slow KDE startups try increasing this setting until performance improves: