NFS mounted and unmounted shell script

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 08-06-2015
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,

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

Smilie Not worked

2)
Code:
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

Smilie 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

Last edited by rbatte1; 08-07-2015 at 07:08 AM.. Reason: CODE tags
# 2  
Old 08-06-2015
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?
# 3  
Old 08-07-2015
My Server details are:
Code:
[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.
Code:
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 Smilie

Last edited by rbatte1; 08-07-2015 at 07:09 AM.. Reason: CODE tags
Login to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Similar Threads More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Mounted and unmounted khaled_ly84 AIX 5 03-15-2018 03:42 AM
Unable to write to NFS mounted directory anaigini45 HP-UX 3 01-18-2018 10:47 AM
Unable to write to a mounted NFS share Rossdba UNIX for Dummies Questions & Answers 4 09-15-2014 04:07 PM
Hang NFS shell script check crazy_max Shell Programming and Scripting 7 04-10-2014 04:08 PM
Want to improve the rsize and wsize of nfs mounted drives rakeshkumar UNIX for Dummies Questions & Answers 0 07-16-2012 03:52 AM
NFS mounted drive showing Write protected message rakeshkumar UNIX for Dummies Questions & Answers 0 06-14-2012 07:45 AM
doubt in NFS mounted filesystem in linux anshu ranjan Red Hat 1 07-07-2011 01:03 AM
if (disk is mounted) unmount if (disk is unmounted) mount hollister Shell Programming and Scripting 2 03-11-2011 07:51 PM
NFS mounted files Harleyrci Solaris 12 10-08-2010 03:25 PM
Kill shell script when host program not running/disk unmounted pcwiz Shell Programming and Scripting 2 10-02-2009 11:04 AM
VNC + GNOME with nfs mounted homedirs. Esaia UNIX Desktop Questions & Answers 0 12-04-2008 03:11 AM
Not able to use NFS mounted directory as buffer for untar & unzip. suraj.bc Programming 0 04-08-2008 08:11 AM
Remote mount an already mounted nfs filesystem itsupplies Solaris 1 09-19-2006 10:31 PM
Testing if nfs filesystem is mounted xadamz23 Shell Programming and Scripting 2 03-15-2006 05:40 PM
How can I tell if a filesystem is NFS mounted? giannicello UNIX for Dummies Questions & Answers 3 09-23-2002 03:13 PM
All times are GMT -4. The time now is 10:41 PM.

Unix & Linux Forums Content Copyright 1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password





Not a Forum Member?
Forgot Password?