Unix/Linux Go Back    


How to Post in the The UNIX and Linux Forums Tutorials for how to post and interact in the forums.

NFS mounted and unmounted shell script

How to Post in the The UNIX and Linux Forums


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 08-06-2015   -   Original Discussion by Santosh101
Santosh101's Unix or Linux Image
Santosh101 Santosh101 is offline
Registered User
 
Join Date: Aug 2015
Last Activity: 14 September 2015, 2:18 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
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.

Linux 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

Linux 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
Sponsored Links
    #2  
Old Unix and Linux 08-06-2015   -   Original Discussion by Santosh101
jim mcnamara's Unix or Linux Image
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 21 June 2018, 9:11 PM EDT
Location: NM
Posts: 11,416
Thanks: 629
Thanked 1,170 Times in 1,077 Posts
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?
Sponsored Links
    #3  
Old Unix and Linux 08-07-2015   -   Original Discussion by Santosh101
Santosh101's Unix or Linux Image
Santosh101 Santosh101 is offline
Registered User
 
Join Date: Aug 2015
Last Activity: 14 September 2015, 2:18 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
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 Linux

Last edited by rbatte1; 08-07-2015 at 06:09 AM.. Reason: CODE tags
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
if (disk is mounted) unmount if (disk is unmounted) mount hollister Shell Programming and Scripting 2 03-11-2011 06:51 PM
NFS mounted files Harleyrci Solaris 12 10-08-2010 02:25 PM
Kill shell script when host program not running/disk unmounted pcwiz Shell Programming and Scripting 2 10-02-2009 10:04 AM
Testing if nfs filesystem is mounted xadamz23 Shell Programming and Scripting 2 03-15-2006 04:40 PM
How can I tell if a filesystem is NFS mounted? giannicello UNIX for Dummies Questions & Answers 3 09-23-2002 02:13 PM



All times are GMT -4. The time now is 11:55 PM.