0% found this document useful (0 votes)
4 views

install nfs

This guide provides step-by-step instructions for setting up an NFS server and client on CentOS 7, allowing users to mount remote directories. It covers the installation of necessary packages, configuration of shared directories, and setting up permanent mounts. Additionally, it includes commands for verifying connections and managing firewall settings to ensure proper access.

Uploaded by

arifin faathir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

install nfs

This guide provides step-by-step instructions for setting up an NFS server and client on CentOS 7, allowing users to mount remote directories. It covers the installation of necessary packages, configuration of shared directories, and setting up permanent mounts. Additionally, it includes commands for verifying connections and managing firewall settings to ensure proper access.

Uploaded by

arifin faathir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

https://www.howtoforge.

com/nfs-server-and-client-on-centos-7

https://www.golinuxcloud.com/show-nfs-shares-list-nfs-client-mount-points/

NFS Server and Client Installation on CentOS 7


On this page
1 Preliminary Note
2 At NFS server end
3 NFS client end
4 Permanent NFS mounting
5 Links
This guide explains how to configure an NFS server on CentOS 7. Network File System
(NFS) is a popular distributed filesystem protocol that enables users to mount
remote directories on their server. NFS lets you leverage storage space in a
different location and allows you to write onto the same space from multiple
servers or clients in an effortless manner. It, thus, works fairly well for
directories that users need to access frequently. This tutorial explains the
process of mounting an NFS share on a CentOS 7.6 server in simple and easy-to-
follow steps.

1 Preliminary Note
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:

yum install nfs-utils


Now create the directory that will be shared by NFS:

mkdir /var/nfsshare
Change the permissions of the folder as follows:

chmod -R 755 /var/nfsshare


chown nfsnobody:nfsnobody /var/nfsshare
We use /var/nfsshare as a shared folder, if we use another drive such as the /home
directory, then the permission changes will cause a massive permissions problem and
ruin the whole hierarchy. So in case, we want to share the /home directory then
permissions must not be changed.
Next, we need to start the services and enable them to be started at boot time.

systemctl enable rpcbind


systemctl enable nfs-server
systemctl enable nfs-lock
systemctl enable nfs-idmap
systemctl restart rpcbind
systemctl restart nfs-server
systemctl restart nfs-lock
systemctl restart nfs-idmap
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:

systemctl restart nfs-server


Again we need to add the NFS service override in CentOS 7 firewall-cmd public zone
service as:

firewall-cmd --permanent --zone=public --add-service=nfs


firewall-cmd --permanent --zone=public --add-service=mountd
firewall-cmd --permanent --zone=public --add-service=rpc-bind
firewall-cmd --reload
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:

yum install nfs-utils


Now create the NFS directory mount points:

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:

mount -t nfs 192.168.0.100:/home /mnt/nfs/home/


It will mount /home of NFS server. Next we will mount the /var/nfsshare directory:

mount -t nfs 192.168.0.100:/var/nfsshare /mnt/nfs/var/nfsshare/


Now we are connected with the NFS share, we will crosscheck it as follows:
Advertisement

df -kh
[root@client1 ~]# df -kh
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 39G 1.1G 38G 3% /
devtmpfs 488M 0 488M 0% /dev
tmpfs 494M 0 494M 0% /dev/shm
tmpfs 494M 6.7M 487M 2% /run
tmpfs 494M 0 494M 0% /sys/fs/cgroup
/dev/mapper/centos-home 19G 33M 19G 1% /home
/dev/sda1 497M 126M 372M 26% /boot
192.168.0.100:/var/nfsshare 39G 980M 38G 3% /mnt/nfs/var/nfsshare
192.168.0.100:/home 19G 33M 19G 1% /mnt/nfs/home
[root@client1 ~]#
So we are connected with the NFS share.

Now we will check the read/write permissions in the shared path. At client enter
the command:

touch /mnt/nfs/var/nfsshare/test_nfs
So we successfully configured an NFS-share.

4 Permanent NFS mounting


We have to re-mount the NFS share at the client after every reboot. Here are the
steps to mount it permanently by adding the NFS-share in /etc/fstab file of client
machine:

nano /etc/fstab
Add the entries like this:

[...]
erpdb:/backup /backup_sap nfs vers=3,rsize=8192,wsize=8192,timeo=14,intr
0 0
192.168.0.100:/home /mnt/nfs/home nfs defaults 0 0
192.168.0.100:/var/nfsshare /mnt/nfs/var/nfsshare nfs defaults 0 0
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 :)

Melihat client mana saja yg mapping


[root@backupserver ~]# showmount -a 10.50.0.56
All mount points on 10.50.0.56:
10.50.0.128:/backup56
10.50.0.134:/backup56
10.50.0.166:/backup_usb
10.50.0.180:/backup56
10.50.0.187:/backup_usb
10.50.0.190:/backup_usb
10.50.0.224:/backup_usb
10.50.0.23:/backup_usb
10.50.0.31:/backup56
10.50.0.32:/backup56
10.50.0.33:/backup56
10.50.0.34:/backup56
10.50.0.35:/backup56
10.50.0.36:/backup56
10.50.0.37:/backup56
10.50.0.38:/backup56
10.50.0.45:/backup56
10.50.0.46:/backup56
10.50.0.47:/backup56
10.50.0.48:/backup56
10.50.0.49:/backup56
10.50.0.50:/backup56
10.50.0.73:/backup_usb
10.50.0.76:/backup_usb
10.50.0.82:/backup_usb

You might also like