NFS mounted and unmounted shell script

Hi,
I making a script to check nfs mount and unmount options.
After various findings, i didn't get any solution for that.
Can you please help me in making the script.

1) I have used,

if grep -qs '/var/JETSHARE' /proc/mounts; then
   echo "It's mounted."
else
   echo "It's not mounted.

:mad: Not worked

2)

mountPart=/var/JETSHARE
rootId=$(stat -c%d /)
mountId=$(stat -c%d "${mountPart}")
if (( rootId == mountId ))
then
   echo "code for not mounted"
else
   echo  "code for mounted"
fi

:mad: Not worked

3) I am unable to trace out the filesystem (df -h) when NFS is unmounted. Box is in hung state when it is unmounted.

So, how can I know from the script when the nfs is unmounted

Exactly what Linux/UNIX are you using? I am guessing CentOS.

Do you know about /etc/mnttab or etc/mtab (if it exists on your system)?

/proc/mounts has a specific format, if I understand correctly it has a column that specifies the status. So, simply finding the mountpoint in there may nort be what you want?

My Server details are:

[root@fedora17-64-base etc]# uname -a
Linux fedora17-64-base.ibminternal.com 3.6.10-2.fc17.x86_64 #1 SMP Tue Dec 11 18:07:34 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

/etc/mtab location:

/etc/mtab is a link to the /proc/mounts.

lrwxrwxrwx. 1 ibm ibm 12 Dec 26  2014 /etc/mtab -> /proc/mounts

please help me to find out NFS file system is available to my NFS client or not using shell scripting .

Thanks in advance :slight_smile: