How To Mount Nfs In Linux

Network File System (NFS) is a distributed file system protocol that allows a user on a client computer to access files over a network much like local storage is accessed. Today, we will walk through the steps of mounting an NFS in Linux.

Prerequisites

Before starting, make sure that you have root or sudo privileges on the Linux system where you will be setting up NFS.

Step 1: Install NFS

The first step is installing NFS. On Debian-based systems like Ubuntu, you can use the apt-get command:

    sudo apt-get install nfs-common
    

And on Red Hat-based systems such as CentOS, you can use the yum command:

    sudo yum install nfs-utils
    

Step 2: Create the Directory to Mount the NFS Share

Then, create a directory where you will mount the NFS share. For instance, if you want to create a directory called /mnt/nfs:

    sudo mkdir /mnt/nfs
    

Step 3: Mount the NFS Share

Now, use the mount command to mount the NFS share. Replace the NFS server IP and NFS share path with your actual server IP address and NFS path:

    sudo mount -t nfs 192.168.1.10:/path/to/nfs /mnt/nfs
    

Here, -t nfs defines the type of file system. The server’s IP address is 192.168.1.10 and /path/to/nfs is the path to the NFS directory on the server. /mnt/nfs is the local directory where the NFS share will be mounted.

Step 4: Verify the NFS Share

Finally, verify that the NFS share is properly mounted using the df command:

    df -h
    

This command will list all the mounted file systems, and you should see your NFS share in the list.

Conclusion

So, this is how you can mount NFS in Linux. It is a straightforward process that involves installing the necessary software, creating a mount point, and then mounting the NFS share. The ability to share files over the network is an important aspect of system administration, and the NFS service provides a way to do this in Linux environments.