#! /bin/bash ### reference: https://www.itzgeek.com/how-tos/linux/centos-how-tos/how-to-setup-nfs-server-on-centos-7-rhel-7-fedora-22.html ### This script mount an nfs hardisk located in server $ipnsf to the directory $nfs_dir in the current node running this script # Use this script only in a node but not in the frontend # Check NFS Share # Before mounting the NFS share directory in local node ('NFS client'), check the NFS shares available on the NFS server by running the following command on the NFS client. ipnfs=192.168.1.22 #### this is the ip address of the NFS host where the external hardisk is sitting showmount -e $ipnfs # Mount the shared directory in the NFS clients. nfs_dir is the name of the shared directory in $ipnfs nfs_dir=/state/partition1/ext_storage2 mkdir $nfs_dir echo '$ipnfs':'$nfs_dir $nfs_dir' $ipnfs':'$nfs_dir $nfs_dir mount $ipnfs':'$nfs_dir $nfs_dir ## customize permission of $nfs_dir #chmod -R 775 $nfs_dir #chown -R root:users $nfs_dir echo 'see me?' #Verify the mounted share on the NFS client using mount command. #mount | grep nfs #Also, you can use the df -hT command to check the mounted NFS share. df -hT #Create a file on the mounted directory to verify the read and write access on NFS share. #touch $nfs_dir'/test_'$HOSTNAME #If the above command returns no error, you have working NFS setup # To mount the shares automatically on every reboot, you would need to modify /etc/fstab file of your NFS client. cp /etc/fstab /etc/fstab.orig echo $ipnfs':'$nfs_dir $nfs_dir ' nfs nosuid,rw,sync,hard,intr 0 0' >> /etc/fstab # Reload the entries in the modified /etc/fstab, by using the mount command: mount -av