1 Preliminary Note: Tutorial
1 Preliminary Note: Tutorial
I have fresh installed CentOS 7 server, on which I am going to install the NFS server.
My CentOS server have hostname server1.example.com and IP
as 192.168.0.100
If you don't have a CentOS server installed yet, use this tutorial for the basic operating
system installation. Additionally to the server, we need a CentOS 7 client machine, this
can be either a server or desktop system. In my case, I will use a CentOS 7 desktop
with hostname client1.example.com and IP 192.168.0.101 as a client. I will
run all the commands in this tutorial as the root user.
2 At NFS server end
As the first step, we will install these packages on the CentOS server with yum:
mkdir /var/nfsshare
Now we will share the NFS directory over the network a follows:
nano /etc/exports
We will make two sharing points /home and /var/nfsshare. Edit the exports file as
follows:
/var/nfsshare 192.168.0.101(rw,sync,no_root_squash,no_all_squash)
/home 192.168.0.101(rw,sync,no_root_squash,no_all_squash)
Note 192.168.0.101 is the IP of the client machine, if you wish that any other client
should access it you need to add it IP wise otherwise you can add "*" instead of IP for
all IP access.
Condition is that it must be pingable at both ends.
Finally, start the NFS service:
Again we need to add the NFS service override in CentOS 7 firewall-cmd public zone
service as:
Note: If it will be not done, then it will give error for Connection Time Out at client
side.
Now we are ready with the NFS server part.
3 NFS client end
In my case, I have a CentOS 7 desktop as client. Other CentOS versions will also work
the same way. Install the nfs-utild package as follows:
mkdir -p /mnt/nfs/home
mkdir -p /mnt/nfs/var/nfsshare
Next, we will mount the NFS shared home directory in the client machine as shown
below:
It will mount /home of NFS server. Next we will mount the /var/nfsshare directory:
Now we are connected with the NFS share, we will crosscheck it as follows:
df -kh
touch /mnt/nfs/var/nfsshare/test_nfs
nano /etc/fstab
Note 192.168.0.100 is the server NFS-share IP address, it will vary in your case.
This will make the permanent mount of the NFS-share. Now you can reboot the
machine and mount points will be permanent even after the reboot.
Cheers, now we have a successfully configured NFS-server over CentOS 7 :)
5 Links
CentOS: http://www.centos.org/