With NFS, we can mount remote directories on our Redhat system and work with the remote files as if they were local files. I’ve followed this blog to setup an NFS Server on my AD VM.
Installing NFS Client Packages
Inorder for us to mount NFS shares on our Redhat VM, we will need to install an NFS client package.
Setup NFS Shared Storage
Shared Storage is used to connect all our Redhat hosts so we will just use a standard NFS Config here. Create two directories as shown to serve as our local mount point for the exported Software and VM data stores shares.
[root@rhev-01 /]# mkdir -p /nfsdata/datavol01
[root@rhev-01 /]# mkdir -p /nfsdata/datavol02
[root@rhev-01 /]# mkdir -p /nfsdata/softwares
[root@rhev-01 /]#
[root@rhev-01 /]# ls -ltrh /nfsdata/
total 0
drwxr-xr-x. 2 root root 6 Nov 29 12:17 datavol01
drwxr-xr-x. 2 root root 6 Nov 29 12:17 datavol02
drwxr-xr-x. 2 root root 6 Nov 29 12:17 softwares
Mount the NFS share by running the mount command
£Syntax - mount -t NFSServerIP:/exporteddir /local mountpoint
mount -t nfs 192.168.11.10:/NFS-DataVol01 /nfsdata/datavol01
mount -t nfs 192.168.11.10:/NFS-DataVol02 /nfsdata/datavol02
mount -t nfs 192.168.11.10:/NFS-Software /nfsdata/softwares
Verify that the remote NFS volume is successfully mounted using running the mount or df
command.
[root@rhev-01 /]# df -H
192.168.11.10:/NFS-DataVol01 484G 116M 484G 1% /nfsdata/datavol01
192.168.11.10:/NFS-DataVol02 484G 116M 484G 1% /nfsdata/datavol02
192.168.11.10:/NFS-Software 484G 116M 484G 1% /nfsdata/softwares
[root@rhev-01 /]#
Making NFS Mount Persistent
A point to remember is that for the NFS shares to be mounted automatically when the system reboots, an entry needs to be added to the /etc/fstab so the remote directory can get mounted on reboots.
Syntax - NFSServerIP:/exporteddir /local protocol defaults options
[root@rhev-01 /]# tail -5 /etc/fstab
/dev/mapper/rhel_sfo--m01--vc02-swap none swap defaults 0 0
192.168.11.10:/NFS-DataVol01 /nfsdata/datavol01 nfs defaults 0 0
192.168.11.10:/NFS-DataVol01 /nfsdata/datavol02 nfs defaults 0 0
192.168.11.10:/NFS-Software /nfsdata/softwares nfs defaults 0 0
Verify that the remote NFS volume is successfully mounted using running the mount or df
command.
[root@rhev-01 /]# df -H
192.168.11.10:/NFS-DataVol01 484G 116M 484G 1% /nfsdata/datavol01
192.168.11.10:/NFS-DataVol02 484G 116M 484G 1% /nfsdata/datavol02
192.168.11.10:/NFS-Software 484G 116M 484G 1% /nfsdata/softwares
[root@rhev-01 /]#
Verify that the remote NFS volume is successfully mounted using running the mount or df
command.
[root@rhev-01 /]# mount -av
/nfsdata/datavol01 : already mounted
/nfsdata/datavol02 : successfully mounted
/nfsdata/softwares : already mounted
[root@rhev-01 /]#
Verify Storage pool
Unmounting NFS File Systems
In case we need to unmount a NFS Mounted Share all we need to do is to run the command unmount
£Syntax - umount /local mountpoint
umount /nfsdata/softwares
Finally, we will also need to remove the entry from the /etc/fstab file.