How To Create NFS Share and Mount Shared Directory on a Client On Centos

 

NFS is the abbreviation of the Network File System. NFS is a useful technology for file sharing. It works as a server and client model. In this article we will share a directory as nfs share on a server and mount this directory to a client.

To use NFS technology, we need to install the following package on both servers.

After installing the nfs-utils package, we need to activate and start the nfs service as follows.

We enable the service.

We are starting the enabled service

If we want to check the service after the above operations are done, we can use the following command.

If the result is returning as shown in the screenshot above, your nfs service is running.

After seeing that our NFS service works on both sides, we can proceed to the next step.

We are going to the server where we want to share the folder and make the following configurations.

First enter “/etc/exports” with the vi command and write the following command into this file by changing according to your environment.

For example, you can use the following command.

Descriptions of the screenshot above:

Part 1: The directory you want to share.

Part 2: Client IP

Part 3: Specifies the permissions in the specified directory.

After completing the above operations, we execute the following command.

After completing the necessary operations on the server, let’s move on to the client.

After connecting to the client, we run the following command to insert into the fstab.

After adding the necessary information to fstab as above, we save and exit.

After saving, run the command below to mount.

When we check the directories on the client machine with the command “df -h“, we will see that nfs share is mounted.