Skip to content

NFS

The Network File System (NFS), is an internet standard protocol used by Linux, UNIX, and similar operating systems as their native network file system.

NFS servers export shares) and NFS clients mount an exported share to a local mount point.

Mount NFS Shares

Temporarily mount an NFS share using the mount command:

sudo mount -t nfs -o rw,sync remoteserver:/share /mount

Persistently mount an NFS share using /etc/fstab:

remoteserver:/share nfs  rw,sync  0 0

Use the nfsconf tool to manage NFS client and server configuration files to get, set, or unset NFS configuration parameters. It updates the /etc/nfs.conf configuration file.

Examples:

nfsconf --set nfsd vers4.2 y
nfsconf --get nfsd vers4.2
nfsconf --unset nfsd vers4.2

To configure an NFSv4-only client:

nfsconf --set nfsd udp n
nfsconf --set nfsd vers2 n
nfsconf --set nfsd vers3 n

Automounter

The automounter is a service autofs that automatically mounts NFS shares "on-demand," and automatically unmounts NFS shares when they are no longer used.

Install the autofs package:

dnf install autofs nfs-utils

Add a master map file to /etc/auto.master.d:

vi /etc/auto.master.d/example.autofs
/shares  /etc/auto.example
Create the mapping file:

/etc/auto.example
*     -rw,hard,intr         192.168.122.200:/nfsdata/&
*     -rw,sync,fstype=nfs4  server.example.com:/shares/&

Start the autofs service:

systemctl enable  autofs
systemctl start autofs

Example of direct mapping:

/-  /etc/auto.direct

Summary

Mount and unmount an NFS export from the command line. Configure an NFS export to mount at startup automatically. Configure the automounter with direct and indirect maps, and describe their differences. Configure NFS clients to use NFSv4 using the new nfsconf tool.

Command References:

mount, umount, fstab, nfsconf, autofs.