
In this tutorial i will show you how to setup a NFS server and client on Redhat 7 / CentOS 7
The same steps can be used in Fedora based systems also instead of yum you have to use dnf.
NFS stands for Network File System which allows end systems to mount file systems over a network and interact with those as they are mounted locally
Redhat 7 added support to the NFS version 4.1 , which has a lot of performance and security
NFS Server Setup
For setting up the nfs server we need a CentOS 7 or redhat 7 , i am using CentOS 7 as NFS server and RHEL 7 as client
Step 1 : Install the nfs packages
yum -y install nfs-utils libnfsidmapStep 2 : Start the NFS services and enable the services to work even after reboots
- systemctl start rpcbind
- systemctl enable rpcbind
- systemctl start nfs-server
- systemctl enable nfs-server
- systemctl start nfs-lock
- systemctl start nfs-idmap
Create a folder in your server and provide the necessary permissions , i created a folder under "/" partition and providing 777 to it
mkdir /myshare
chmod 777 /myshareNow we need to make a entry in /etc/exports file to make the share available on the client systems
/myshare 192.168.211.140(rw,sync,no_root_squash)where
- /myshare - is the shared folder to the clients
- 19.168.211.140 - NFS server ip
- rw - Allows to read and write on the shared dir
- ro - Allows to read the contents in the shared dir
- sync - allows to sync
- no_root_squash - Any file request made by user root on the client machine is treated as made by user nfsnobody in the server
exportfs -a
Step 4 : Configure Firewall
we need to add the below rules on nfs server, so that clients can access the shared dir
firewall-cmd --permanent --zone public --add-service mountd
firewall-cmd --permanent --zone public --add-service nfs
firewall-cmd --permanent --zone public --add-service rpc-bind
firewall-cmd --reload
NFS Client Setup
Step 1 : Install the nfs pacakges on clientyum -y install nfs-utils libnfsidmapStep 2 : Start the necessary services
- systemctl start rpcbind
- systemctl enable rpcbind
- systemctl start nfs-server
- systemctl enable nfs-server
- systemctl start nfs-lock
- systemctl start nfs-idmap
showmount -e serverip
Step 3 : Mount the shared dir on the client
mount -t nfs {NFS server ip}:(shared dir) (Mountpoint)eg :
mount -t nfs 192.168.211.140:/myshare /mnt
Step 4 : Verify it
For checking use df -h or mount command
Post A Comment:
0 comments: