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.
1 |
yum -y install nfs-utils |
After installing the nfs-utils package, we need to activate and start the nfs service as follows.
We enable the service.
1 |
systemctl enable nfs-server.service |
We are starting the enabled service
1 |
systemctl start nfs-server.service |
If we want to check the service after the above operations are done, we can use the following command.
1 |
systemctl status nfs-server.service |
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.
1 |
/home/paylasm secondary_sunucunun_ipsi(rw,sync,no_root_squash,no_subtree_check) |
For example, you can use the following command.
1 |
/home/paylasm 216.58.206.195(rw,sync,no_root_squash,no_subtree_check) |
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.
1 |
exportfs -a |
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.
1 |
vi /etc/fstab |
After adding the necessary information to fstab as above, we save and exit.
After saving, run the command below to mount.
1 |
mount -a |
When we check the directories on the client machine with the command “df -h
“, we will see that nfs share is mounted.