A network file system (NFS) is a type of file system that enables the storage and retrieval of data from multiple disks and directories across a shared network.
With NFS you can mount remote directories on your own system. This mount lets you access remote directories as if they are on your own system just like local files.
In this tutorial, let’s see how we can mount an NFS share on Linux systems.
Mounting NFS share on a Linux system requires the NFS client package. Installing this package is very easy but package name differs from Linux distro to distro. So below are the commands for various Linux distros to install the client package.
sudo apt-get install nfs-common
sudo pacman -S nfs-utils
sudo yum install nfs-utils
Run above commands on both NFS client and NFS server machines. The above command will install all support files including NFS portmap daemon.
Mounting a remote NFS file system is similar to mounting a regular file system. To mount an NFS directory we need to follow the steps below.
First, let’s start by creating a directory to serve as the mount point for the remote NFS share:
sudo mkdir /mnt/share
This directory will be used as a mount point, here mount point is a directory on the local machine where NFS share is mounted.
Now let’s mount the NFS share, Run this command with sudo privileges:
sudo mount -t nfs 192.168.1.10:/share /mnt/share
Here 192.168.1.10 is the NFS server’s IP address, /share is the remote directory on the server, while /mnt/share is the local mount point.
After this command is successfully run no output will be produced. So let’s do a quick test, type the following commands on your client.
cd /mnt/share
mkdir working
Then do a quick check on server if it’s there
cd /share
ls
Now there should be the working directory in /share. But this mount is temporary and will not last after reboot. To make this NFS share permanent on our system across reboots we need to make an entry in /etc/fstab.
We don’t want to manually mount the NFS file system after every reboot. So for that, we need to add an entry in /etc/fstab. As /etc/fstab contains a list of entries that mounts file systems on system startup.
So to edit /etc/fstab open that file in your favorite editor.
sudo nano /etc/fstab
This will open fstab, now just add the following line in the file.
192.168.1.10:/share /mnt/share nfs defaults 0 0
Here, 192.168.1.10 is the IP address of server, /share is the directory on the server and /mnt/share is the local mount point. And here 0 0 are for dump and pass, 0 for dump means it will not be backed up automatically while 0 for pass means the system will not check for errors at boot time.
When you are done or are no longer in need of the NFS file system you will need to Unmount NFS.
To unmount an NFS share umount command is used, just see the examples below.
umount 192.168.1.10:/share
umount /mnt/share
Use any of the above following commands it will do the work. If you have an entry in fstab file you will also need to remove that line.
This is how to mount NFS in Linux. We hope you like this tutorial and if you like it do share it with your friends. Here are the 10 best text editors for Linux, do take a look at it and tell which one you like the most.
You can utilize a wide range of tools as a Linux user to keep organized, manage your time, and become… Read More
Have you ever caught yourself in a situation where you need details of an audio/ video media file? When you… Read More
If you have installed Linux alongside windows in the dual boot you might have noticed that every time you boot… Read More
Linux kernel is like the core of the operating system. It's a piece of software that works as a middle… Read More
Nowadays, most Linux Distros already have Python preinstalled. But you might have a distribution that might not have Python preinstalled.… Read More
Python is one of the most popular and easy to learn programming languages. Its a widely used high-level programming language… Read More
Just so that you know we use cookies on our website. Want to know more
read here