Developed by Sun Microsystems in 1984, NFS or Network File Shares is a file system protocol used for accessing files over a network similar to a local storage device.
NFS Shares are powerful and popular as they allow users to share files and directories over a local network and the internet. However, it is better to limit NFS shares to local and trusted networks as files don’t get encrypted on the machines. However, the problem was addressed and fixed on a recent version of the NFS protocol. You may need to set up complex authentication methods such as Kerberos.
This tutorial will walk you through how to set up NFS shares on a Linux system. Let us get started.
Setting up NFS Server
Let us start by setting up the NFS server. This process is fairly simple, with only a few commands:
sudo apt-get install nfs-kernel-server
Next, create a directory in the local system which will be used as the NFS’ share root directory:
Set the appropriate permissions to the directory:
Next, edit the exports file in /etc/exports and add the following entry
Setting Up An NFS Client
For you to mount NFS Shares on Linux, you will need to install nfs client tools using the command:
Mounting an NFS Filesystem
The process of mounting NFS file shares is very similar to mounting a regular file system in Linux. You can use the command mount. The general syntax is as:
To accomplish this, start by creating a directory to use as the NFS Share’s mount point.
Next, mount the NFS share using the mount command as shown below:
Once completed, you should have access to the remote shares on the server.
Unmounting File shares
Since an NFS share is similar to a file system, you can unmount it with umount command as:
You can use other options with umount command, such as a force to force-unmount the NFS shares.
The above is a simple guide on how to use and mount NFS shares on a Linux system. There is more to NFS than what we have discussed here; feel free to utilize external resources to learn more.