Network Filesystem (NFS)

How to set up an NFS server and client on CentOS

NFS is a distributed filesystem that allows you to mount a partition from an NFS server on the network by using the NFS client.

The server in this example will be named “puppet” with an IP address of

Start the portmap service
Every time you start the NFS service a dynamic port number gets assigned with the portmapper service. So we need to start it before NFS.

/sbin/chkconfig portmap on
/etc/init.d/portmap start

Install NFS software on the CentOS Server

yum -y install nfs-utils nfs-utils-lib

Make NFS start at boot, and start services

/sbin/chkconfig nfs on
/etc/init.d/nfs start

Create a directory to share, we will call it /nfs_share

mkdir /nfs_share

Define shares in /etc/exports
Note the IP address below is for the client side of things.

echo "/nfs_share,sync,no_root_squash,no_subtree_check)" >> /etc/exports

Run exportfs -a
Every time that we make changes to /etc/exports, this command must be run to make the changes take effect.

exportfs -a

Client side setup

Now that we have the server up and have allowed access to /nfs_share to the ip address, we can setup that client.

Install nfs software on client, same way as above

yum -y install nfs-utils nfs-utils-lib

Now we can mount the partition

mount /mnt

Run df to see it mounted

df -h

Optionally you can add a line like this to /etc/fstab
If you add it to fstab, it will mount automatically on reboots. /mnt nfs rw,sync,hard,intr 0 0