28.04.2023

How to mount NFS share on CentOS

Introduction

NFS is a net file system access protocol. It provides remote access to file system objects, and allows working with them as if they were local.

Next, we'll look on mount process of distributed file system resource on CentOS.

Any actions must be performed with elevated rights.

At the beginning, we deploy additional software on the client where we plan connect the remote directory.

To do this, open the terminal and insert command there:

sudo dnf install nfs-utils

This will install packages for NFS protocol support and management tools.

Finding an NFS share

After that we must to decide which the NFS directory we wish to connect. Do this by insert the command on the client server:

showmount -e "Server IP"

This will list all available shared directories.

Create a mount point

Now we create the so-called mount point. It represents the folder where the distributed file system resource will be mounted. It can be created anywhere on the file system, but is usually located in the /mnt directory. It is created with the following command:

sudo mkdir /mnt/nshare

Mounting an NFS share

Everything is ready to mount the NFS share. We execute the command:

sudo mount "IP -nfs server :/share /mnt/nshare

For example, for the server IP - 10.10.1.1, NFS share - /home/nshare, the command will look like this:

sudo mount 10.10.1.1:/home/nshare /mnt/nshare

Installation check

To verify that the resource was successfully mounted, you can run:

df –H

The output of the command will list all mounted file systems.

It should show the NFS share mounted to the /mnt/nshare directory. To be able to automatically mount the NFS resource at each startup, you can edit the /etc/fstab file with any convenient text editor by adding the following line there:

/mnt/nshare nfs defaults 0 0

After editing, you must save the file and exit the text editor. Now the NFS share will be automatically mounted every time the server is started.

Conclusion

The article looked at how to mount an NFS share in CentOS 8. Following it, you can easily access files and directories located on remote servers and work with them as if they were local.

You may be also interested in