Get NFS mount/export config

A simple commands useful for systems assessment on linux servers.

It gets:

  • NSF mounts configured in /etc/fstab
  • NFS mounts active on the system
  • Host-IP lookup for the above results
  • NFS exports configured in /etc/exports
  • Host-IP lookup for the above results

in human readable format.

clear; \
echo -e "\033[0;31m######## `hostname` ######## \033[0m"; echo " "; \
echo -e "\033[0;31m### NFS mounts on /etc/fstab\033[0m"; \
  grep ' nfs ' /etc/fstab; echo " "; \
echo -e "\033[0;31m### Active NFS mounts\033[0m"; \
  mount |grep ' nfs '; echo " "; \
echo -e "\033[0;31m### Hosts/IP used by mounts\033[0m"; \
  mount |grep ' nfs ' |cut -d ':' -f 1 |xargs -n1 ping -c1 |grep PING |cut -d ' ' -f 2,3; \
echo " "; echo " "; \
echo -e "\033[0;31m### NFS exports\033[0m"; \
  cat /etc/exports |grep -v '#' |grep '/'; echo " "; \
echo -e "\033[0;31m### Hosts/IP used in exports\033[0m"; \
  cat /etc/exports |grep -v '#' |grep '/' |sed -e 's/([^()]*)//g' |cut -d ' ' -f2-200 |xargs -n1 ping -c1 |grep PING |cut -d ' ' -f 2,3; echo " ";