Setting up an NFS Server on CentOS

You can convert a plain CentOS machine into an NFS server by installing the NFS Linux packages and configuring access to the shared directories. Here's a simple step-by-step guide to help you get this setup.

Step 1 - Download and Install the Required NFS Software

Start by downloading and installing the required NFS packages on both the NFS server and the client.

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

Start the appropriate NFS services on the server.

chkconfig nfs on
service rpcbind start
service nfs start
service nfslock start

Start the rpcbind service on the client.

service rpcbind start

Step 2 - Export Appropriate Shared Directories

Next step is to export appropriate directories on your NFS server so that they are accessible via NFS clients. You do this by adding the appropriate directory to /etc/exports file, which specifies both the directory to be shared and the details of how it is shared.

Edit the /etc/exports file:

vi /etc/exports

Add the following line to the file:


where /foo is the directory you are trying to export.

Add entries to the /etc/exports file for each directory you wish to export.

Once that's done, export the directories:

exportfs -a

Step 3 - Mount the exported directory

Mount the exported directory on /mnt.

mount -o vers=3 /foo /mnt

October 14, 2015