Linux Mint

How to Install and Configure an NFS Server on Linux Mint21

File sharing is one of the major issues Linux users faces, especially transferring files from one system to another though there are some easy ways to transfer a file. Using the NFS tool on Linux Mint is the best way to share files between other systems as long as all the systems are connected to a network. So, if you are interested in sharing files and looking for an easy-to-use tool then try NFS and for that read this guide.

How to Install NFS Server on Linux Mint 21

There are few steps that are mentioned in this guide to install NFS server on Linux Mint 21:

Step 1: Update the package list of the apt package manager as it is a good practice:

$ sudo apt update

Step 2: Next, install the NFS server on your Linux Mint using the default package manager:

$ sudo apt install nfs-kernel-server -y

How to Setup and Use NFS Server on Linux Mint 21

Once the server is installed there are few settings that one need to do in order to use this server effectively, below are some steps for configuring the NFS server:

Step 1: Create a directory for NFS that can be named according to the user preference, for instance I have created a directory named share:

$ sudo mkdir -p /mnt/share

Step 2: Change the ownership of the directory to a group user and for that execute:

$ sudo chown -R nobody:nogroup /mnt/share/

Next change the directory permissions and give the permission accordingly by using the chmod command:

$ sudo chmod 777 /mnt/share/

Step 3: Now grant access to the NFS server and for that open the exports file using:

$ sudo nano /etc/exports

Next enter the IP address of your system to grant access to others, here I have used the below given syntax to give access:

/mnt/share <IP-address>(rw,sync,no_subtree_check)

Now save the changes made in file and afterwards export the file by using:

$ sudo exportfs -a

Step 4: Next, to apply the changes restart the NFS server and for that use:

$ sudo systemctl restart nfs-kernel-server

Step 5: Now allow the client system through the firewall of Linux Mint and for that use:

$ sudo ufw allow from 192.168.18.72 to any port nfs

Next enable the firewall of Linux Mint using:

$ sudo ufw enable

Next check the status if the client IP is allowed through the firewall of Linux Mint and for that execute:

$ sudo ufw status

Step 6: Now install NFS client on Linux Mint and for that use:

$ sudo apt install nfs-common

 Step 7: Now create a directory for the client and for that use:

$ sudo mkdir -p /mnt/clientshare

Step 8: Now mount the NFS server with the client directory using the IP address of client by following the given syntax:

$ sudo mount <IP-Address>:/mnt/share /mnt/clientshare

Step 9: Now move to the NFS share directory using change command:

$ cd /mnt/share/

Testing NFS server on Linux Mint 21

Now all the settings are done so let’s test the NFS and for first create two test files, for that use the echo command with tee command like this:

$ echo “Test File for NFS” | tee myfile1.txt myfile2.txt

Now check the client directory using ls command and you will find both files in that directory which were created in the NFS server directory:

$ ls -l /mnt/clientshare/

Removing NFS Server From Linux Mint 21

To completely remove NFS from Linux Mint one needs to remove the NFS kernel server and NFS client, below are steps to remove both NFS server and NFS client:

Step 1: To remove NFS server completely from Linux Mint 21 use:

$ sudo apt remove nfs-kernel-server

Step 2: Now to remove the NFS client from Linux Mint 21 execute:

$ sudo apt remove nfs-common

Conclusion

The NFS tool on Linux Mint is the best way to share files between other systems as long as all the systems are connected to a network. To use NFS one needs to have an NFS client and server installed on a Linux system, this guide gives a detailed process on not only installing NFS but also using it.

About the author

Aaliyan Javaid

I am an electrical engineer and a technical blogger. My keen interest in embedded systems has led me to write and share my knowledge about them.