How to configure NFS Server in RedHat Enterprise Linux

Posted: 27 Dec 2016 in LINUX
Tags: , , , , , , ,

NFS(Network File System) is a distribute File System Protocol which is used to share data over network.We configure a Linux Machine as a NFS Server and the data get stored on SERVER Machine and then get distributed to different linux client machines over network. Here in this tutorial we will learn how to configure that NFS server in RedHat Enterprise Linux  and then also learn what to do at client side to access data shared by NFS server over network.


nfs server linux

Step1: Install packages required for nfs.


[root@localhost ~]# yum install nfs* -y
[root@localhost ~]# yum install portmap* -y


Step2: Configure /etc/exports file

/etc/exports file is that file which controls which file systems are exported to remote host or remote client machines.


nfs server

Explanation of few important keywords used in NFS /etc/exports file:

ro–> means remote hosts can read only mounted file system.


rw–> means remote hosts can read and write i.e you can say remote hosts are allowed to make some changes in mounted file system.


async –> this options allows the server to write or make changes at non-regular intervals.


sync –> when we use sync options then all files writes are committed to the disk.But sync option little lower the performance.


root_squash –> this option is used to prevent root users conncted remotely to nfs server though root privileges.


Now there are several methods to share data with nfs clients over a network and System Admin or you can say the person seating on SERVER MACHINE can decide with whom to share the folder and whom not.He/she can allow a single host or a complete network or can share different folder for different users.To understand this see the below examples for /etc/exports file:


/linuxtiwary *(rw,sync)  :This will share data to everyone coonected with the NFS server.


/satish,sync) :This will share data over network only with ip and no other ip can mount,read or write the data on NFS SERVER machine.


/tiwary,sync):This will allows all the 254 host in this network to read and write data on NFS SERVER.It means every ip in this network can mount the /tiwary folder which is on NFS SERVER to their local Machine and read and and make changes there too.


Step3:Now create the folder or directory you have mentioned in above file and create some demo files inside them for testing.

nfs directory

Step4:start the services requires to run NFS. nfs service

Step5:Now it,s time to export Folder created on NFS SERVER TO SHARE WITH THE CLIENT MACHINES USING exportfs coomand.


Exportfs -a will allow all file to get exported.

exportfs -r will refresh the /etc/exports file changes.


Step6:Now Check which folders are ready for share over network using showmount command.


[root@localhost ~]# showmount  -e
Export list for localhost.localdomain:
/linuxtiwary *
[root@localhost ~]#


Step7: Now Client Side Configuration.

First see the mountable data from server using showmount.

nfs mount

Then create a directory and mount the NFS Server data there.

Then check it using df -h whether it is mounted or not.

mount nfs data

then make permanent entry of nfs mount using /etc/fstab file.

fstab file


Step8:Now if you want to stop nfs server sharing go to server and do the below things.

First stop the nfs service.

[root@localhost ~]# service nfs stop

Stop the /etc/exports file from sharing over network.

[root@localhost ~]# exportfs -u

exportfs – u command unexport all shares.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.