How to Set Up and Configure NFS Server and Clients

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

The needed packages are nfs and rpcbind, install them by yum or dnf:

# yum install nfs-utils rpcbind

Configure /etc/exports to give clients the permission to use the NFS directories.

Edit /etc/exports

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:

/home 10.0.0.1/24(rw)

For details of the exports functions, please refer to export manual.

Start up the NFS service

Enable nfs service on the NFS server so that the NFS service daemon automatically starts each time the server starts:

# /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.

Client-slide configuration

Package installation

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

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

One comment:

Leave a Reply

Your email address will not be published. Required fields are marked *