Sponsored Content
Top Forums Shell Programming and Scripting How to check if a partition is mounted or not with bash? Post 302466201 by KenJackson on Monday 25th of October 2010 10:51:47 PM
Old 10-25-2010
Or grep /proc/mounts (or /etc/mtab) directly:
Code:
if grep -q <partition> /proc/mounts; then
    echo "It's mounted"
fi

 

10 More Discussions You Might Find Interesting

1. SCO

/ partition is mounted but not present in mount

Hello , I 've got a problem with the root partition on my SCO 5.0.5 . When I check the disk with df or mount , I can 't see the root filesystem . # mount /stand on /dev/boot read only on Tue Sep 05 16:13:51 2006 /home on /dev/home read/write on Tue Sep 05 16:14:41 2006 But , if I try... (3 Replies)
Discussion started by: npn35
3 Replies

2. UNIX for Dummies Questions & Answers

Solaris10:How to check where /usr are really mounted

How can I check which partition /usr are mounted on ? Usually this is mounted on root (/). If I want to move /usr to another partition, how do I do this ? BR Ludwig (1 Reply)
Discussion started by: ludwig
1 Replies

3. Solaris

swap partition showing mounted in df -h

Dear All Anyone can help me what is the problem of swap partition? swap partition is showing mounted in df -h command output. Regards prakash (1 Reply)
Discussion started by: pshelke
1 Replies

4. Shell Programming and Scripting

How to display partition name on mounted on using this script

Hi All Guys.... root> df -k|grep /u0 /dev/vx/dsk/oradg/u02vol 12582912 8717924 3744252 70% /u02 /dev/vx/dsk/oradg/u01vol 8796160 5563610 3131556 64% /u01 /dev/vx/dsk/oradg/u04vol 10035200 1247888 8519534 13% /u04 /dev/vx/dsk/oradg/u03vol 12582912 2524060 9744542 21% ... (3 Replies)
Discussion started by: adzuanamir
3 Replies

5. Shell Programming and Scripting

bash script to check if mounted, and mount if not

I'd like to make a wrapper bash script that will make sure that an nfs mount is mounted before launching a program that depends on the mount being active. Basically: 1) Check to see if the mount is active 2) If it's not active, try to mount it 3) If it won't mount because the nfs server is... (3 Replies)
Discussion started by: graysky
3 Replies

6. Shell Programming and Scripting

Check if NAS filesystem is mounted

Anyone know the best way to check and see if a NAS filesystem is mounted on a linux box. I have no idea where to start :wall:. (2 Replies)
Discussion started by: d3mon_spawn
2 Replies

7. Solaris

Check mounted filesystems

Hi, Please help me to tell How to check mounted filesystems for any inconsistency. Can I run fsck -m /dev/rdsk/cntndnsn for this? Thanks, (3 Replies)
Discussion started by: Manmohan Mishra
3 Replies

8. Windows & DOS: Issues & Discussions

How to check if the folders in mounted on which partition?

Hi there, I am able to check which parition from Storage > Disk Management How is it possible to check if the folder is mounted on which partition. (1 Reply)
Discussion started by: alvinoo
1 Replies

9. Shell Programming and Scripting

Help with code to check if file systems are mounted

Hi I need to have a piece of code that check if all file systems are mounted or not. I have to pieces of information like the output of the bdfcommand, and the file /etc/fstab. The first is: bdf Filesystem kbytes used avail %used Mounted on /dev/vg00/lvol3 2097152 266656... (3 Replies)
Discussion started by: fretagi
3 Replies

10. Shell Programming and Scripting

Script to check if file systems are mounted

Hi I have the following piece of code, running on a solaris 10 O.S., that is not working for NFS file systems: for vol in `grep -E 'vxfs|ufs|nfs' /etc/vfstab | egrep -v '^#' | awk '{ print $3 }'` do if df -k $vol | grep $vol > /dev/null then outputOK "Filesystem: $vol mounted" else... (1 Reply)
Discussion started by: fretagi
1 Replies
FIXMOUNT(8)						      System Manager's Manual						       FIXMOUNT(8)

NAME
fixmount - fix remote mount entries SYNOPSIS
fixmount [ -adervq ] [ -h name ] host ... DESCRIPTION
fixmount is a variant of showmount(8) that can delete bogus mount entries in remote mountd(8C) daemons. The actions specified by the options are performed for each host in turn. OPTIONS
-a -d -e These options work as in showmount(8) except that only entries pertaining to the local host are printed. -r Removes those remote mount entries on host that do not correspond to current mounts, i.e., which are left-over from a crash or are the result of improper mount protocol. The actuality of mounts is verified using the entries in /etc/mtab. -v Verify remote mounts. Similar to -r except that only a notification message is printed for each bogus entry found. The remote mount table is not changed. -A Issues a command to the remote mountd declaring that ALL of its filesystems have been unmounted. This should be used with caution, as it removes all remote mount entries pertaining to the local system, whether or not any filesystems are still mounted locally. -q Be quiet. Suppresses error messages due to timeouts and "Program not registered", i.e., due to remote hosts not supporting RPC or not running mountd. -h name Pretend the local hostname is name. This is useful after the local hostname has been changed and rmtab entries using the old name remain on a remote machine. Unfortunately, most mountd's won't be able to successfully handle removal of such entries, so this option is useful in combination with -v only. This option also saves time as comparisons of remotely recorded and local hostnames by address are avoided. FILES
/etc/mtab List of current mounts. /etc/rmtab Backup file for remote mount entries on NFS server. SEE ALSO
showmount(8), mtab(5), rmtab(5), mountd(8C). BUGS
No attempt is made to verify the information in /etc/mtab itself. Since swap file mounts are not recorded in /etc/mtab, a heuristic specific to SunOS is used to determine whether such a mount is actual (replacing the string "swap" with "root" and verifying the resulting path). Symbolic links on the server will cause the path in the remote entry to differ from the one in /etc/mtab. To catch those cases, a filesys- tem is also deemed mounted if its local mount point is identical to the remote entry. I.e., on a SunOS diskless client, server:/export/share/sunos.4.1.1 is actually /usr/share. Since the local mount point is /usr/share as well this will be handled correctly. There is no way to clear a stale entry in a remote mountd after the local hostname (or whatever reverse name resolution returns for it) has been changed. To take care of these cases, the remote /etc/rmtab file has to be edited and mountd restarted. The RPC timeouts for mountd calls can only be changed by recompiling. The defaults are 2 seconds for client handle creation and 5 seconds for RPC calls. 26 Feb 1993 FIXMOUNT(8)
All times are GMT -4. The time now is 09:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy