How To Setup an NFS Server and Client For File Sharing

In this tutorial, I will explain how to set up an NFS server and client configurations for mounting an NFS share across systems in a network.[alert style=”e.g. white,

[alert style=”e.g. white, grey, red, yellow, green”] Note: This tutorial is based on Ubuntu 14.04 server. You can create a VM easily on the cloud or using vagrant. [/alert]

Setup an NFS server

In this setup, I have a ubuntu server with IP address

1. Refresh the apt package index

2. Install the NFS package.

3. Next, we need to create a directory that can be shared with other hosts in the network. I am going to create a folder in var directory.

4. Change the ownership of the NFS folder to “nobody” and “nogroup”.

The “nobody” is a user present in most of the Linux distros which belong to the “nogroup” which does not have any privileges on the system programs or files.

5. All the NFS configurations are set in the /etc/exports file. In which we can give specific permissions for a client to access the files in the share.

In this example, I have a client with IP Open the exports file and make an entry as shown below.

6. NFS table holds all the exports of the shares. You can create one using the following command.

READ  How To Setup Kubernetes API Access Using Service Account

7. Now, let’s start the NFS service.

That’s it! We have an NFS server up and running.

Setup NFS client Node

All the servers which need access to the NFS share need to install the NFS client packages.

1. Refresh the apt list and install the client package.

2. Let’s create a folder that will be mounted to the remote NFS share.

3. Now, mount the remote NFS directory with out local /mnt/nfs directory.

4. Verify the mount using the following command. You will see NFS share listed in the file system.

The output looks like the following.

5. Now you can test the share by creating a test file in /var/nfs folder of the NFS server and try to list that in your clients /mnt/nfs folder.

That’s it! You now have an NFS share server and client up and running. You can add more clients in the same way we set up our first client.

Free DevOps Resources

Get DevOps news, tutorials and resources in your inbox. A perfect way If you want to get started with devops. Like you, we dont like spam.