NFS Server and Client Configurations
NFS Server Configuration
The main configuration of the NFS server is done in the /etc/exports file; this file has two elements: a directory to share, and a host with mount options. You can reload the server or use exportfs -ra.
Common options include root squashing, read size, write size, and read/write.
The syntax of the exports file is:
<DIRECTORY> <HOST OR NETWORK>(<OPTIONS>)
Sharing the /srv/nfs/ directory would have an entry like the one below:
/srv/nfs/ 192.168.122.0/24(rw,sync,root_squash)
NFS Client Configuration
The NFS client mounts the remote filesystem on to the local system. There are a couple of commands specific to NFS:
-
showmount command queries the mount daemon on the remote server for information, including the shares that are available for mounting:
# showmount -e SERVER
Export list for SERVER:
/srv/exports *
-
portmap daemon is a dynamic port mapping daemon designed to reduce the usage of well-known port numbers. It is still used by NFS up to version 3, but not required by NFS version 4. It is required for the
showmount
command. -
mount command has the filesystem type NFS, which links to the mount.nfs command. There are two formats of the mount command for NFS shares.
-
One option for mounting NFS shares is
mount HOST:/export /mount-point
where thehost:/export
portion causes the mount command to process this mount as NFS. -
The other form of the mount command is
mount -t NFS HOST:/export /mountpoint
which specifies which NFS is being used.
-
# mount SERVER:/share /mnt/share