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


Prerequisites
Check if the required packages are installed

# rpm -qa | grep nfs
nfs-utils-1.2.3-15.el6.i686
nfs-utils-lib-1.1.5-4.el6.i686
nfs4-acl-tools-0.3.3-5.el6.i686
In Red Hat 5 or CentOS 5
# rpm -qa | grep portmap
portmap-4.0-65.2.2.1

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

# yum -y install nfs
# vi /etc/exports
/NFS 10.10.10.0/24(no_root_squash,sync,rw)

/NFS  ==>  shared directory
10.10.10.0/24  ==>  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 10.10.10.90:/NFS /mnt