NFS is widely deployed and used even after more than twenty year. NFS is easy to set up and easy to use. This introduces how to set up the NFS server and clients. We use the Fedora system as the example. The tutorial here is for RHEL/CentOS/Fedora and derived Linux OSes.
Set up an NFS Server
Table of Contents
The needed packages are
rpcbind, install them by
# yum install nfs-utils rpcbind
Configure /etc/exports to give clients the permission to use the NFS directories.
For example, to allow the servers inside subnet 10.0.0.1/24 to mount the /home directory with read/write permission. Add this line to /etc/exports:
For details of the exports functions, please refer to export manual.
Start up the NFS service
# /sbin/chkconfig rpcbind on # /sbin/chkconfig nfs on
You may also manually start it
# service rpcbind start # Note: always start/restart rpcbind before nfs # service nfs start
I repeat it again as it is so important: always start/restart rpcbind before nfs.
If the server is configured with firewall, allow the ports needed by NFS. During tests when you are not sure whether it’s the firewall settings that causes problems, you may try to flush the iptables rules by
# iptables -F and enable it back after you are sure NFS service is working fine and debug the firewall settings.
Install the nfs-utils package:
# yum nfs-utils
Start the rpcbind service
Start the service needed by NFS:
# service rpcbind restart
You may also set it to start automatically
# chkconfig rpcbind on
Mount the NFS directory
You can mount the NFS directory to the mount point:
# mount NFS_SERVER:/home/userdir MOUNT_POINT
where NFS_SERVER is the NFS server’s address, and MOUNT_POINT is the local mount point on the client side for the NFS directory.
You may also consider using autofs on top of NFS as described in Unified Linux Login and Home Directory Using OpenLDAP and NFS/automount.
NFS debugging tips
When you find problems, these tips may give you some clues on what’s wrong and the results here are useful when you ask some others for help.
On the server side
# service nfs status
# service rpcbind status
# rpcinfo -p localhost
# showmount -e localhost
# netstat -ptuln
# iptables -S
On the client side
# showmount -e $SERVER_IP
# rpcinfo -p $SERVER_IP
# iptables -S