Sponsored Content
Contact Us Post Here to Contact Site Administrators and Moderators How to Post in the The UNIX and Linux Forums NFS mounted and unmounted shell script Post 302951441 by Santosh101 on Thursday 6th of August 2015 11:17:30 AM
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
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How can I tell if a filesystem is NFS mounted?

I would like to know if there is a command or set of commands that I can run to verify that there are no 'extraneous' nfs mounted filesystems on our server. I didn't see anything in doing a search on NFS. We think that we may have some filesystems that are still nfs mounted when the link should... (3 Replies)
Discussion started by: giannicello
3 Replies

2. Shell Programming and Scripting

Testing if nfs filesystem is mounted

Hello, I have a backup script that backs up my system to a nfs mounted file system. The mount point on my local system is /backup. I want my script to check whether the nfs file system is mounted on /backup before actually backing anything up. Even if the nfs file system was NOT mounted,... (2 Replies)
Discussion started by: xadamz23
2 Replies

3. UNIX Desktop Questions & Answers

VNC + GNOME with nfs mounted homedirs.

Hi! I'm experiencing some disturbing problems with a machine at work. I've got about 20 users and of which 15 uses VNC to connect to the machine for working with GNOME. The problem is that after a while it seems like the homedir get some nfs stales or something, gnome processes hangs and so... (0 Replies)
Discussion started by: Esaia
0 Replies

4. Shell Programming and Scripting

Kill shell script when host program not running/disk unmounted

I have my Mac OS X program executing a shell script (a script that copies files to a drive). I want to make it so that the shell script automatically kills itself if it finds that the host .app is not running OR kill itself if the drive that it is copying files to has been unmounted. Right now what... (2 Replies)
Discussion started by: pcwiz
2 Replies

5. Solaris

NFS mounted files

If I am not a system admin. How can I tell where a particular mounted file is mounted from. (12 Replies)
Discussion started by: Harleyrci
12 Replies

6. Shell Programming and Scripting

if (disk is mounted) unmount if (disk is unmounted) mount

Hey there, sorry if this is a bit too much of a noob question, trying to get to grips with a simple bash script - but i have done ZERO bash scripting. basically having worked out how to mount and unmount disks using: disktool -m *device* & disktool -e *device* - and looking at the result of... (2 Replies)
Discussion started by: hollister
2 Replies

7. Red Hat

doubt in NFS mounted filesystem in linux

Hi, I have some filesystem which is nfs mounted and shared to other servers. Nfs server name= nfsserver (here filesystem is locally mounted) server name where filesystem is shared = sharedserver1 and sharedserver2 filesystem which is shared = /filesystem1 when i am checking utilization by... (1 Reply)
Discussion started by: anshu ranjan
1 Replies

8. UNIX for Dummies Questions & Answers

Unable to write to a mounted NFS share

Hi All, I created a nfs share in the server(Solaris 10) with the following command and also updated the dfstab file share -F nfs -o rw=server_name2,anon=0 /to_share And then in the client(solaris 10) added the following command to mount the share mount -F nfs server_name1:/to_share... (4 Replies)
Discussion started by: Rossdba
4 Replies

9. HP-UX

Unable to write to NFS mounted directory

Hi, I have exported a few nfs mounts from one server to the nfs clients. This is my nfs server dfstab : # cat /etc/dfs/dfstab # place share(1M) commands here for automatic execution # on entering init state 3. # # share <pathname> # .e.g, # share -F... (3 Replies)
Discussion started by: anaigini45
3 Replies

10. AIX

Mounted and unmounted

Hi Guys I'm new here, and I need urgent help. This my first steps to be Aix admin and I have this task -instal Oracle database on Aix machine and create mounting point /u02 of size 100GB for Oracle Standalone database installation. -download and install the following OS patches - IV42025... (5 Replies)
Discussion started by: khaled_ly84
5 Replies
UMOUNT(8)						    BSD System Manager's Manual 						 UMOUNT(8)

NAME
umount -- unmount filesystems SYNOPSIS
umount [-fv] special | node umount -a | -A [-fv] [-h host] [-t type] DESCRIPTION
The umount command calls the unmount(2) system call to remove a special device or the remote node (rhost:path) from the filesystem tree at the point node. If either special or node are not provided, the appropriate information is taken from the list of filesystems provided by getfsent(3). The options are as follows: -a All the filesystems described via getfsent(3) are unmounted. -A All the currently mounted filesystems except the root are unmounted. -f The filesystem is forcibly unmounted. Active special devices continue to work, but all other files return errors if further accesses are attempted. The root filesystem cannot be forcibly unmounted. -h host Only filesystems mounted from the specified host will be unmounted. This option implies the -A option and, unless otherwise speci- fied with the -t option, will only unmount NFS filesystems. -t type Is used to indicate the actions should only be taken on filesystems of the specified type. More than one type may be specified in a comma separated list. The list of filesystem types can be prefixed with ``no'' to specify the filesystem types for which action should not be taken. For example, the umount command: umount -A -t nfs,hfs umounts all currently-mounted filesystems of the type NFS and HFS. (The -a option only unmounts entries in the /etc/fstab list.) -v Verbose, additional information is printed out as each filesystem is unmounted. NOTES
Due to the complex and interwoven nature of Mac OS X, umount may fail often. It is recommended that diskutil(1) (as in, ``diskutil unmount /mnt'') be used instead. SEE ALSO
unmount(2), getfsent(3), mount(8), diskutil(1) HISTORY
A umount command appeared in Version 6 AT&T UNIX. 4th Berkeley Distribution May 8, 1995 4th Berkeley Distribution
All times are GMT -4. The time now is 08:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy