Setup NFS Mounts on Ubuntu 16.04 LTS Servers for Client Computers to Access

For Linux admins and students, NFS is one of the many ways to allow client computers to access network resources. It’s easy to setup and manage and suitable to allow public access to  network resources.

NFS or Network File System, is a distributed file system that can be enabled in a client/server environment. NFS is very easy to configure for those wishing to allow NFS client machines to access NFS mount points on a server using NFS protocol.

This brief tutorial shows users how to setup NFS mount points on a server for client access. It should be quick and easy to understand, even for new users.

For this tutorial, we’re going to be using two systems:

  1. Server Computer with IP address
  2. Client Computer with IP address
  3. Share Resource Namepublicdata

Step 1: Installing NFS Server packages on the Host computer

To get NFS server working you must install the server packages. To do that run the commands below:

sudo apt-get update
sudo apt-get install nfs-kernel-server

When the server packages are installed, switch to the client to install the client package.

Step 2: Installing NFS client packages on the client systems

To access NFS mount points on the server, you must install NFS client packages. To do that, run the commands below

sudo apt-get update
sudo apt-get install nfs-common

After installing the client packages, switch to the server to configure a mount point to export to the client.

Step 3: Creating the folder/directory to export (share) to the NFS clients

Now that the server and client components of NFS have been installed, you can now go and create the folder or directory you which to export to the clients.

For this tutorial, we’re creating a folder called publicdata in the /mnt/ directory. To create the folder, run the command below.

sudo mkdir -p /mnt/publicdata

Since we want this location to be viewed by all clients, we’re going to remove the restrictive permissions. To do that, change the folder permission to be owned by nobody in no group.

sudo chown nobody:nogroup /mnt/publicdata
sudo chmod 777 /mnt/publicdata

Now the folder is ready to be exported so the client can access it. Sub folders can be created there as well.

Step 4: Configuring NFS Exports file

Now that the location is created on the host system, open NFS export file and define the client access.

Access can be granted to a single client or entire network subnet. For this tutorial, we’re allowing access to the single client mentioned above.

NFS export file is at /etc/exports

In that file is where you define client access. The configuration format is:

/server_share_resource          client_IP(share option1, .. share_optionN)

So, permit access to only the client with IP To do that, open the export file by running the commands below:

sudo nano /etc/exports

Then add the line below:


and save the file. Only client with IP address defined above will access that location remotely.

To allow an entire subnet


The options in the setting above are: rw= read/write, sync=write changes to disk before applying and no_subtree_check= prevents subtree checking.

Export the shares by running the commands below

sudo exportfs -a

Restart the NFS server by running the commands below.

sudo systemctl restart nfs-kernel-server

Step 5: Mounting the NFS share on the client

Next, switch to the client to mount the NFS directory defined on the server. To do that, create a mount point on the client where the host mount will mounted. This can be anywhere.

sudo mkdir -p /mnt/publicdata

After creating the mounting point, use the command below to mount the server NFS folder on the client

The format to mount directories on the client is as shown below:

sudo mount server_IP:/NFS_directory_on_server   /client_mount_point

sudo mount /mnt/publicdata

This command above mounts the directory on the client computer.

You can automatically mount the directory by editing the /etc/fstab file by adding the lines below and saving the file.

sudo nano /etc/fstab

Then add the line below and save. /mnt/publicdata nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0

To un-mount the folder, use the umount command.

sudo umount /mnt/publicdata

If for some reasons the client can’t access the host folder, open Ubuntu firewall to the client on the host computer.

sudo ufw allow from to any port nfs

That’s it!

This is how to setup an NFS mount for clients in a client/server environment using NFS protocol.


You may also like the post below: