Setup NFS server on CentOS 7

Scenario: How to setup NFS server and NFS client.
– CentOS 7 NFS server IP Address:
– CentOS 6 NFS client IP Address:

1) Configure NFS server
– Install NFS packages on the CentOS server with yum:
yum install nfs-utils

– Create the directory that will be shared by NFS:
mkdir /NFSdisk

– Change the permissions of the folder as follows:
chmod -R 755 /NFSdisk
chown nfsnobody:nfsnobody /NFSdisk

– Start service and enable at boot:
systemctl enable rpcbind
systemctl enable nfs-server
systemctl enable nfs-lock
systemctl enable nfs-idmap
systemctl start rpcbind
systemctl start nfs-server
systemctl start nfs-lock
systemctl start nfs-idmap

– Edit firewall allow NFS service

firewall-cmd --permanent --zone=public --add-service=nfs
firewall-cmd --permanent --zone=public --add-service=mountd
firewall-cmd --permanent --zone=public --add-service=rpc-bind
firewall-cmd --reload

– Share the NFS directory over the network a follows,in this scenario will share to 4 servers(NFS client):
vi /etc/exports


Note: Whenever we modify /etc/exports, we must run: exportfs -a

2) Example configure NFS client on CentOS/RHEL linux server
– Create the directory where we want to mount the NFS shares
mkdir /dataNFS

– Run below command to temporary mount NFS(will loose if server reboot)
mount -t nfs /dataNFS

[root@centos6 /]# mount -t nfs /dataNFS
[root@centos6 /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolumeGroup-lv_root 9.9G 1.8G 7.6G 20% /
tmpfs 931M 0 931M 0% /dev/shm
/dev/sda1 485M 39M 421M 9% /boot
/dev/mapper/VolumeGroup-lv_opt 2.5G 68M 2.3G 3% /opt
/dev/mapper/VolumeGroup-lv_var 9.9G 199M 9.2G 3% /var
/dev/mapper/VolumeGroup-lv_home 1008M 68M 890M 8% /home 100G 33M 100G 1% /dataNFS
[root@centos6 /]#

– Mount pemanent;y,edit /etc/fstab .
vi /etc/fstab
and place below command /dataNFS nfs defaults 0 0


Leave a Reply

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