How To Setup NFS In Ubuntu 20.04 LTS?
This post was last updated on May 31st, 2020 at 07:10 pm
NFS or Network file system is a distributed filesystem protocol. It allows a remote host to mount filesystem over a network and interact that filesystem much like local storage is accessed.
It follows the client-server model. The mounted filesystem can be accessed by the client with whatever privileges assigned to each file. Ahead in this article, we will discuss to setup NFS in Ubuntu 20.04 LTS.
- 1 How to setup NFS server?
- 2 How to set up the client components of NFS?
- 3 Adjust the firewall settings on NFS server
- 4 Test the NFS setup
How to setup NFS server?
To start file-sharing you need to set up the NFS server and client components of NFS. Now follow the given steps to install the NFS server in Ubuntu 20.04 LTS.
Install NFS server
Open your terminal and execute the following command –
sudo apt-get install nfs-kernel-server nfs-common portmap -y
nfs-common package includes programs such as nfsstat, lockd, statd, showmount, gssd, idmapd, and mount.nfs.
Portmap or rpcbind utility maps RPC services to the port on which they are listening. To display the RPC services along with the information like port they use, their version, etc. Use the following command –
Create an export directory
Create a directory that is to be shared with the clients. You can create a directory by using the following command –
sudo mkdir -p /mnt/nfsshare
Next set the required permission and ownership for the created directory –
sudo chown nobody:nogroup /mnt/nfsshare
Set read, write and execute permission to everyone –
sudo chmod 777 /mnt/nfsshare
Assign the server access to clients
The access of files can be controlled from the server. You can mention clients with the permission that they will have in /etc/exports. First, open /etc/exports file by using the following command –
sudo nano /etc/exports
And then add the following line in this file –
For example –
Similarly, you can add multiple clients. Now save the changes and export the shared directory.
sudo exportfs -avrf
Restart your nfs server to make changes effective –
sudo /etc/init.d/nfs-kernel-server restart
How to set up the client components of NFS?
We will have to make some configuration on the client computer to start using the network file system. Now follow the given steps to set up the client components of nfs –
Install client components
Install the nfs-common and port map or rpcbind on the client computer by using the following command –
sudo apt-get install nfs-common portmap -y
A directory on the client computer is needed where we can access the data shared by the export directory of the nfs server. Use the following command to create a directory –
sudo mkdir -p /mnt/nfsshare_client
Use the following command to mount the client directory-
sudo mount -t nfs ServerIP:/mnt/nfsshare /mnt/nfsshare_client
For example –
sudo mount -t nfs 192.168.122.118:/mnt/nfsshare /mnt/nfsshare_client
You can check if the directory is mounted or not by using –
Adjust the firewall settings on NFS server
You need to modify firewall settings to allow a client to access a port on the server. Use the following command –
sudo ufw allow from clientIP to any port nfs
Check the status of the firewall by using –
sudo ufw status
Test the NFS setup
Now we need to test our NFS setup If you create a file inside the /mnt/nfsshare, the same file will be available in /mnt/nfsshare_client and vice-versa. That means our NFS setup is working fine.
Ok, that’s all for now. You can share your experience in the comments below.
You might also like
This post was last updated on September 15th, 2019 at 05:39 pmA process is an instance of a computer program that is currently running. A program can have multiple instances
The yum and dnf are the command line package management utilities that can be used for installation, updating, and removal of a software package. These are used in the CentOS,
Suppose you have an archive file of size more than 5GB, and if you want to burn it on a disc or transfer it to a filesystem with limited max