Creating an NFS Share Between Two Linux Instances

If you ever have the need for a share between Linux instances there are only a few quick steps that have to be followed to make it happen. The example configuration shown below is for RedHat/Centos 6.

Hosts used in this example:

    primary.savvco.com
    secondary.savvco.com

Login to primary.savvco.com as ROOT. The server primary.savvco.com will serve as the main source for the share

 ssh root@primary.savvco.com  

Create a folder for the share

 mkdir /share  

Edit the /etc/exports file on primary.savvco.com and add an entry allowing access to the share for the secondary host

 vi /etc/exports  
 /share   secondary.savvco.com(rw,sync,no_root_squash)  
 :wq  

Verify the NFS Service. If the NFS Service is enabled and running, you will need to restart the service for the changes to the /etc/exports file to take effect

 service nfs status  
 service nfs restart  

The NFS service is not enabled by default in RedHat/Centos. In order for the new share to become permanent on primary.savvco.com the service needs to be enabled

 chkconfig nfs on  

— Steps for the primary host are completed —

To continue, login to secondary.savvco.com as ROOT

 ssh root@secondary.savvco.com  

Create a folder for the share

 mkdir /share  

There are two methods for mounting the share from secondary.savvco.com

Temporary Method — will not be available after a reboot

 mount -t nfs -o rw primary.savvco.com:/share /share  

Permanent Method — will be available after a reboot

 vi /etc/fstab  
 primary.savvco.com:/share  /share    nfs   rw,suid     0 0  
 :wq  

— This completes all the necessary steps for setting up an NFS Share on Linux —

PLEASE NOTE: If the primary host is inaccessible when rebooting the secondary host configured with the Permanent Method, the secondary host may hang endlessly