How to Install the Network File System (NFS) on ubuntu server 20.04

Louis SanchezAugust 15th 2021, 5:42

Network File System (NFS) is a distributed filesystem protocol that allows clients to access remote files and directories as if they are available on the local system

You will need two Ubuntu systems: one as a central NFS server and another as a client.

Host - 192.168.1.160
Client - - 192.168.1.161

Follow these steps to install NFS:

Step 1 : First, we need to install the NFS server

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

Step 2 : Create the directories to be shared

sudo mkdir /var/nfs

Step 3 : Add this directory to NFS exports under /etc/exports

sudo nano /etc/exports

Step 4 : Add the following line to /etc/exports

/var/nfs	*(rw,sync,no_subtree_check)

Step 5 : Save and close the exports file. Now, restart the NFS service

sudo service nfs-kernel-server restart

Step 6 : Next, we need to configure the client system to access NFS shares.

Step 7 : Create a mount point for NFS shares.

Step 8 : Install the nfs-common package on the client side:

sudo apt-get install nfs-common
sudo mkdir -p /var/nfsshare

Step 9 : Mount the NFS shared directory on the newly-created mount point:

sudo mount 192.168.1.160:/var/nfs /var/nfsshare

Step 10 : Confirm the mounted share with the following command

mount -t nfs

Step 11 : Now, change the directory to /var/nfsshare, and you are ready to use NFS.