How to configure NFS server in Linux

Network File System (NFS) is used to transfer data within multiple Linux systems.

These are the steps you need to follow to configure NFS server in RedHat and CentOS operating system

Check if the required packages are installed

# rpm -qa | grep nfs
In Red Hat 5 or CentOS 5
# rpm -qa | grep portmap

In Redhat 6 or CentOS 6
# rpm -qa | grep rpcbind
If the packages are missing you can install them using yum

# yum -y install nfs
# vi /etc/exports

/NFS  ==>  shared directory  ==>  range of allowed IP
no_root_squash  ==>  by default the NFS is mounted as nobody user with limited permission but using this option you will allow clients to mount with root privilege.
sync  ==>  by default async behavior is used by NFS, sync is used as it moves the data to a stable storage as soon as the NFS is mounted to reduce data corruption chances.
rw  ==>  read write privilege

Restart the NFS server services

# service nfs restart
# service portmap restart

To update your exports file

# exportfs -a

To view your exports file

# exportfs -v

On the Client machine
(Make sure portmap service is running on the client machine)

# mount -t nfs /mnt