How To Configure NFS Service In Linux?

1. Introduction to NFS.

The Network File System (NFS) is one of the most popular services of Linux operating system and it is specially designed to access remote file system over the network. This service is mainly based on the concept of RPC (Remote Procedure Call). This means that clients can access the partitions of remote machine as if they are local hard disks. This means that with the help of NFS service one can share files faster over the network.

2. Prerequisite.

The purpose of this is HOW TO document a complete step-by-step knowledge on configuration of NFS service. In setting up NFS, we need to follow two step procedures; first one is to configure NFS server and then configuration of NFS client. As far as, configuration of NFS is concerned, you need to check that NFS service daemon is installed on your Linux machine. You can check the same by executing following command:

# rpm –qa | grep nfs

Normally, our NFS service listen on standard port no 2049 and 111. This is generally managed by a daemon known as portmap so; you should also make sure that portmap service is running on your Linux Box.

3. Setting up NFS server.

Here, in this documentation it is assumed that you are going to set up both server and client for NFS. For the purpose of this documentation, we are going to see two Linux boxes. One with IP address which will act as NFS server and another one is which is going to be configured as NFS client.

To setup NFS server, you need to follow two step procedures: Making required changes in NFS configuration files and the second one is starting NFS service.

Setting up NFS configuration file.

The main configuration file for NFS is /etc/exports. This file contains a list of entries of all those file systems that needs to be shared across the network. A typical entry of exports file is as follows:


/Path-to-Folder to be shared Name of IP of machine or Network (Options)


/Userdata (rw,sync)

Here, in the above mentioned example, /Userdata is the complete path of the folder on our server machine and it needs to be shared across the network.

Then, is the network ID who have access to this shared folder. You can also specify individual IP of the machine as well as Domain name of a PC here.

And, in the option field, one can specify different options like:

ro - Read Only, means client machine can’t make any changes to shared folder.

rw - Read Write means client machine can change or modify in shared folder.

sync - Generally in all version of NFS service, exportfs will make use of async behavior. This means that client machine knows that file write is completed. It has been written on some stable storage. But, there are chances of data corruption in this kind of behavior and if you make use of sync option then you can prevent this.

root_squash - This option prevents users with having root level privileges and NFS server will actually assign them a userID called nfsnobody. This means it squashes the actual power of root to any local user. This will prevent unauthorized access to our server. To disable this we can specify option no_root_squash.

async - This option is used to speed up the transfer of files.

no_subtree_check - This option is used while we are exporting whole volume so that we can speed up the file transfer.

Let’s have one or two more examples of /etc/exports file:


In the first example mentioned above /usr/local folder is shared only for two machines and in Read Only mode.

Second example, /home folder is shared for the same two machines in Read Write mode.

Third example, /usr/local folder is shared for the whole network in Read Only mode and same way /home folder is shared for the whole network in Read Write mode.

Starting up the NFS service.

Once the required configuration is done in your configuration file then you are required to start the NFS related daemons to make your NFS working.

First, your NFS service depends on portmapper daemon so it needs to be started first.

# service portmap start
# chkconfig portmap on

Once this service is started then you have to start NFS service.

# service nfs start
# chkconfig nfs on

NFS serving is generally managed by five different daemons called rpc.nfsd, this normally performs all the work. Rpc.statd manages the file locking, rpc.mountd, handles initial mount requests and rpc.rquotad, and handles user file quotas on NFS.

Once your NFS service is started, you can confirm it by running following command:

# rpcinfo –p
program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100011 1 udp 749 rquotad
100011 2 udp 749 rquotad
100005 1 udp 759 mountd
100005 1 tcp 761 mountd
100005 2 udp 764 mountd
100005 2 tcp 766 mountd
100005 3 udp 769 mountd
100005 3 tcp 771 mountd
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
300019 1 tcp 830 amd
300019 1 udp 831 amd
100024 1 udp 944 statuses
100024 1 tcp 946 statuses
100021 1 udp 1042 nlockmgr
100021 3 udp 1042 nlockmgr
100021 4 udp 1042 nlockmgr
100021 1 tcp 1629 nlockmgr
100021 3 tcp 1629 nlockmgr
100021 4 tcp 1629 nlockmgr

If you see the following output means your NFS is working properly.

4. Configuring NFS Client.

On client side, first you need to create a mount point:

# mkdir /mnt/nfs_local

Once you are sure, that your client PC is ready then you can run the mount command to export the NFS file system from the server.

# mount /mnt/nfs_local

If this command works successfully then you would be able to see that your file system is successfully mounted in the said folder.

Note: If any kind of error is found during the above mentioned mount command, then you can check my another documentation called NFS troubleshooting.

You can also make entry in to /etc/fstab file to make this file system permanently mount at every reboot. The entry should look like following:

# device mountpoint fs-type options dump fsckord
... /mnt/nfs_local nfs rw,soft 0 0

Bobbin Zachariah 10:00 pm

About Bobbin Zachariah

Founder of LinOxide, passionate lover of Linux and technology writer. Started his career in Linux / Opensource from 2000. Love traveling, blogging and listening music. Reach Bobbin Zachariah about me page and google plus page.

Author Archive Page

Have anything to say?

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

All comments are subject to moderation.