How to configure NFS on CentOS 6

NFSNetwork File System (NFS) is a distributed file system which allows users to access the server file system on their client computer over network. User can use the NFS mounted file system as like as their local file system. The main advantage is to share one file system to many computers by which you can save disk space on the local system. Also we can use this as a centralize server for web applications having many application servers. If you will update your code on one place then it will distributed to all other servers.

In this article I will show you how to configure NFS master and client system. For this I am using two CentOS 6 system.

Master : 192.168.2.100

Client: 192.168.2.200

You need to use the root user for the setup.

Now on the both of the systems issue the below command to install NFS

Add NFS to the startup scripts on the Master:

Now we will export our share directory:

We have to decide which directory we want to share with the client servers. Then we have to add that directory to the /etc/exports file, which specifies both the directory to be shared and the details of how it is shared. In my case I want to share a directory named “/linuxfundacode”

After finishing the configuration we need to issue the below command:

We are done with the NFS server side. Now we will configure the NFS client.

We have already installed the NFS on the client system in First step. Now we need to mount the shared file system to our client machine. Create a directory where you want to mount the NFS file system. For me it’s /var/www/html/www.linuxfunda.com/

Issue the below command to mount

Verify the mount

If you want to make the mount permanent then you have to add the mount informations to the /etc/fstab file.

Save the file after appending the above code. Now the file system will automatically load at the boot time.

Issue the below command to mount the file system immediately.

The following two tabs change content below.

Tapas Mishra

Sr. Engineer (DevOps)
Loves to work on Opensource products. Having experience on Linux environment. Knowledge on Public cloud services like AWS, Rackspace, DigitalOcean, Linode. Please don't hesitate to give a comment on the posts. Your comments are my strength.

Leave a Reply