Home Man
Search
Today's Posts
Register

Tutorials for how to post and interact in the forums.

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.

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

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 06: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

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

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 02:42 AM
Script to check if file systems are mounted fretagi Shell Programming and Scripting 1 05-24-2017 10:48 AM
Filesystem Unmounted Thala AIX 3 01-11-2014 04:00 AM
LVM unmounted due to out of memory venikathir Red Hat 0 10-12-2011 08:34 AM
if (disk is mounted) unmount if (disk is unmounted) mount hollister Shell Programming and Scripting 2 03-11-2011 06:51 PM
Kill shell script when host program not running/disk unmounted pcwiz Shell Programming and Scripting 2 10-02-2009 10:04 AM
bash script to get all mounted devices m0z4rt Shell Programming and Scripting 5 08-08-2009 12:30 AM
How to display partition name on mounted on using this script adzuanamir Shell Programming and Scripting 3 07-07-2008 12:24 AM
file system under /dev have been unmounted Athos19 SCO 1 06-11-2008 07:20 PM
filesystem not getting unmounted nensee7 SCO 1 07-01-2007 12:59 PM


All times are GMT -4. The time now is 05:47 AM.

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