Description:
Network File System (NFS) is a popular distributed file system 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.
Procedure:
NFS Server side:
- First step to install NFS using yum using below command
- Now create directory that need to share using NFS
- Change permission on directory as follow
# chown nfsnobody:nfsnobody /data
- Need to start service and enable them as boot time
# systemctl enable rpcbind
# systemctl enable nfs-server
# systemctl enable nfs-lock
# systemctl enable nfs-idmap
# systemctl start rpcbind
# systemctl start nfs-server
# systemctl start nfs-lock
# systemctl start nfs-idmap
- Share directory over network using following
/var/nfsshare * (rw,sync,no_root_squash,no_all_squash)
/home 10.10.10.10 (rw,sync,no_root_squash,no_all_squash)
Note : 10.10.10.10 is the IP of client machine, if you wish that any other client should access it you need to add the it IP wise other wise you can add "*" instead of IP for all IP access.
- Restart NFS service
- After restart service need to allow NFS port in firewall
# 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
NFS Client Side:
- Install nfs-util using below command
- Create directory to mount from NFS
# mkdir /mnt/home
- After creating directory now mount from NFS using below command:
# mount -t nfs 10.10.10.1:/home /mnt/home
- After mount check storage using below command
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
10.10.10.1:/var/nfsshare 49G 980M 48G 3% /mnt/nfsshare
10.10.10.1:/home 19G 33M 19G 1% /mnt/home
- Now we are connecting NFS shared drive, please check by create test file
Permanent NFS Mounting
- We need to remount after every reboot, so to mount them as permanent by adding NFS share in fstab as follow:
Add entries as follow
10.10.10.1:/var/nfsshare /mnt/nfsshare nfs defaults 0 0
Save file using :wq
- Now check by reboot client machine and directory mounted or not.
No comments:
Post a Comment