// Tutorial //

How To Set Up an NFS Mount on CentOS 6

Published on September 18, 2012
Default avatar
By Etel Sverdlov
Developer and author at DigitalOcean.
How To Set Up an NFS Mount on CentOS 6
Not using CentOS 6?Choose a different version or distribution.
CentOS 6

Status: Deprecated

This article covers a version of CentOS that is no longer supported. If you are currently operating a server running CentOS 6, we highly recommend upgrading or migrating to a supported version of CentOS.

Reason: CentOS 6 reached end of life (EOL) on November 30th, 2020 and no longer receives security patches or updates. For this reason, this guide is no longer maintained.

See Instead:
This guide might still be useful as a reference, but may not work on other CentOS releases. If available, we strongly recommend using a guide written for the version of CentOS you are using.

About NFS (Network File System) Mounts

NFS mounts work to share a directory between several servers. This has the advantage of saving disk space, as the home directory is only kept on one server, and others can connect to it over the network. When setting up mounts, NFS is most effective for permanent fixtures that should always be accessible.


An NFS mount is set up between at least two servers. The machine hosting the shared network is called the server, while the ones that connect to it are called ‘clients’.

This tutorial requires 2 servers: one acting as the server and one as the client. We will set up the server machine first, followed by the client. The following IP addresses will refer to each one:



The system should be set up as root. You can access the root user by typing

sudo su

Setting Up the NFS Server

Step One—Download the Required Software

Start off by using apt-get to install the nfs programs.
yum install nfs-utils nfs-utils-lib
Subsequently, run several startup scripts for the NFS server:
chkconfig nfs on 
service rpcbind start
service nfs start

Step Two—Export the Shared Directory

The next step is to decide which directory we want to share with the client server. The chosen directory should then be added to the /etc/exports file, which specifies both the directory to be shared and the details of how it is shared.

Suppose we wanted to share the directory, /home.

We need to export the directory:

vi /etc/exports

Add the following lines to the bottom of the file, sharing the directory with the client:

/home ,sync,no_root_squash,no_subtree_check)

These settings accomplish several tasks:

  • rw: This option allows the client server to both read and write within the shared directory
  • sync: Sync confirms requests to the shared directory only once the changes have been committed.
  • no_subtree_check: This option prevents the subtree checking. When a shared directory is the subdirectory of a larger filesystem, nfs performs scans of every directory above it, in order to verify its permissions and details. Disabling the subtree check may increase the reliability of NFS, but reduce security.
  • no_root_squash: This phrase allows root to connect to the designated directory

Once you have entered in the settings for each directory, run the following command to export them:

exportfs -a

Setting Up the NFS Client

Step One—Download the Required Software

Start off by using apt-get to install the nfs programs.

yum install nfs-utils nfs-utils-lib

Step Two—Mount the Directories

Once the programs have been downloaded to the the client server, create the directory that will contain the NFS shared files

mkdir -p /mnt/nfs/home

Then go ahead and mount it

mount /mnt/nfs/home

You can use the df -h command to check that the directory has been mounted. You will see it last on the list.

df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda               20G  783M   18G   5% /       20G  785M   18G   5% /mnt/nfs/home

Additionally, use the mount command to see the entire list of mounted file systems.


Your list should look something like this:

/dev/sda on / type ext4 (rw,errors=remount-ro)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw) on /mnt/nfs/home type nfs (rw,noatime,nolock,bg,nfsvers=2,intr,tcp,actimeo=1800,addr=

Testing the NFS Mount

Once you have successfully mounted your NFS directory, you can test that it works by creating a file on the Client and checking its availability on the Server.

Create a file in the directory to try it out:

touch /mnt/nfs/home/example

You should then be able to find the files on the Server in the /home.

ls /home

You can ensure that the mount is always active by adding the directory to the fstab file on the client. This will ensure that the mount starts up after the server reboots.

vi /etc/fstab  /mnt/nfs/home   nfs      auto,noatime,nolock,bg,nfsvers=3,intr,tcp,actimeo=1800 0 0

You can learn more about the fstab options by typing in:

man nfs

After any subsequent server reboots, you can use a single command to mount directories specified in the fstab file:

mount -a

You can check the mounted directories with the two earlier commands:

df -h

Removing the NFS Mount

Should you decide to remove a directory, you can unmount it using the umount command:

sudo umount /directory name

You can see that the mounts were removed by then looking at the filesystem again.

df -h

You should find your selected mounted directory gone.

By Etel Sverdlov

If you’ve enjoyed this tutorial and our broader community, consider checking out our DigitalOcean products which can also help you achieve your development goals.

Learn more here

About the authors
Default avatar
Developer and author at DigitalOcean.

Still looking for an answer?

Was this helpful?

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Hello, i have a problem. I am using

S.O Version: Centos 6.7 Kernel: 2.6.32-573.3.1.el6.centos.plus.x86_64

NFS Version:

nfs-utils-1.2.3-64.el6.x86_64 nfs-utils-lib-1.1.5-11.el6.x86_64



I had no problems installing, I can start the rpcbind smoothly.

But when I start the nfs, I got the following error:

Starting NFS services: [OK] Starting NFS mountd: [OK] Starting NFS Server: rpc.nfsd: unable to resolve ANYADDR: nfs to inet address: servname not supported for ai_socktype rpc.nfsd: unable to set any sockets for nfsd                                                        [FAIL]

When I check the status, that’s the answer I get:

rpc.svcgssd is stopped rpc.mountd (pid 3449) is running … nfsd dead but subsys is locked

I have sought a solution in various forums but without success. Could someone help me, please?

thank you! it’s useful to me

I have two more issues…

  1. NFS mounts are not being mounted after reboot;
  2. When enabling iptables, is not possible to stablish the connection.

ACCEPT tcp – PRIV.ATE.NET.IP/24 anywhere tcp dpt:nfs

I am unable to make it work… I spawned 3 droplets for tests.

The first client hanged for a while but eventually mounted the remote folder.

On the second droplet, the NFS mount justs hangs there… Nothing happens… All three droplets were spawned from the same snapshot of my production server.

Any ideas?

what about security, how do we stop just anyone connecting to the mounted drive?

/home *(rw,sync,no_root_squash,no_subtree_check) i tryed this and it woks thank you

/home,sync,no_root_squash,no_subtree_check we really need specify each client ip address in the nfs server expots

Worked like a charm on Centos 6.5, but auto mount didn’t work unless I ran this command “chkconfig netfs on” Thanks!

Why am I getting this?

[root@*** ~]# chkconfig nfs on [root@*** ~]# service rpcbind start Starting rpcbind: [ OK ] [root@*** ~]# service nfs start FATAL: Module nfsd not found. FATAL: Error running install command for nfsd Starting NFS services: [ OK ] Starting NFS quotas: [ OK ] Starting NFS mountd: [ OK ] Starting NFS daemon: rpc.nfsd: Unable to access /proc/fs/nfsd errno 2 (No such file or directory). Please try, as root, ‘mount -t nfsd nfsd /proc/fs/nfsd’ and then restart rpc.nfsd to correct the problem [FAILED]

@Andrew SB hi thanks for your answer, that’s what I’m trying but does not work with that command. I’ll be down the code to compile and install.