Tutorial: How to set 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 set up.

Step 1 - Download and Install the Required NFS Software

Start by downloading and installing the required NFS packages.

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

Start the appropriate NFS services.

chkconfig nfs on
service rpcbind start
service nfs 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:

/foo 10.1.10.100(rw,sync,no_root_squash,no_subtree_check,insecure)

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

(NOTE: depending on your use case, either all or some of these options will make sense. For more information please reference NFS documentation.)

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

Once that's done, export the directories:

exportfs -a

 


October 14, 2015