- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- checking mount point directory
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2001 07:45 AM
02-22-2001 07:45 AM
test command (and shell built-in test command) has got some operators like "-f", "-x", ... etc.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2001 07:53 AM
02-22-2001 07:53 AM
Re: checking mount point directory
i don't know any test operator for this but here my suggestion:
grep -q " $dir " /etc/mnttab
if [ $? = 0 ]
then
echo "Directory $dir is a mount point"
else
echo "Directory $dir is NOT a mount point"
fi
The variable dir has to be the absolute path.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2001 07:55 AM
02-22-2001 07:55 AM
Re: checking mount point directory
Supposing that $DIRNAME is the name of your directory.
You can do :
if [ $DIRNAME = `bdf $DIRNAME | tail -1 | awk {'print $6}'` ];
then ...
else ...
fi
Regards,
Patrice
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2001 07:58 AM
02-22-2001 07:58 AM
Re: checking mount point directory
One way is to grep for the mountpoint in question in /etc/fstab:
WHAT=/home
if [ `grep -c $WHAT /etc/fstab` -gt 0 ]
then
echo "$WHAT is a mountpoint"
else
echo "$WHAT isn't a mountpoint"
fi
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2001 08:08 AM
02-22-2001 08:08 AM
Re: checking mount point directory
As usual, many ways lead to Rome...
[ $DIR = $(df $DIR | cut -f1 -d" ") ] && echo mount point
DIR must contain a full pathname
Best regards,
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2001 08:17 AM
02-22-2001 08:17 AM
Re: checking mount point directory
To write a simple code i would prefer use of moun command instead of /etc/fstab: mount_point are directory and when it has a file_system mounted is a mount_point
D=/home
MP=`mount | grep -c "^$D "`
echo $MP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2001 08:19 AM
02-22-2001 08:19 AM
Re: checking mount point directory
Other way>
/usr/sbin/mount | cut -d" " -f 1 | grep $(pwd)
if [ $? -eq 0 ]
then
echo "$(pwd) is mount point "
fi
regards, Saa
$(pwd) is actual directory You can change it any variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2001 08:30 AM
02-22-2001 08:30 AM
Re: checking mount point directory
Some of the answers will not work in this :
You have 2 mountpoins :
/firstmountpoint
/firstmountpoint/adirectory/secondmountpoint
If you check /firstmountpoint/adirectory,
some of the previous will answer OK but its false.
My solution works in this case.
Regards,
Patrice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2001 09:22 AM
02-22-2001 09:22 AM
Re: checking mount point directory
Patrice makes a very good point. A better evaluation of /etc/fstab should look like this:
WHAT=[[:space:]]/home[[:space:]]
if [ `grep -c $WHAT /etc/fstab` -gt 0 ]
then
echo "$WHAT is a mountpoint"
else
echo "$WHAT isn't a mountpoint"
fi
This puts white-space surrounding the /home token in the example chosen, and correctly queries /etc/fstab for its presence, unambiguously.
I choose to interrogat /etc/fstab rather with the assumption that one is interested in directories which have been defined for mounting as opposed to directories which are already mounted.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2001 09:42 AM
02-22-2001 09:42 AM
Re: checking mount point directory
James, your script will not work only if you use Service Guard (Mountpoint are in package configuration files)
;-)
Patrice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2001 09:56 AM
02-22-2001 09:56 AM
Re: checking mount point directory
EXCELLENNT POINT!...and I run MC/ServiceGuard too!!!...
One of the things I've done in my cluster's fstab files is to place the pound (#) mark over the device special file name (field-1). This reminds me of the mount point although 'mount' complains mildly during bootup.
With my regards and my thanks for your corrections, Jim. :-))
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2001 02:10 PM
02-22-2001 02:10 PM
Re: checking mount point directory
Maybe you know why i prefer mount command!!
I did not think in S/G neither.
Note my grep contain caret "^" This is begin of line and space " " as separator.
Fine, Patrice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2001 03:12 PM
02-22-2001 03:12 PM
Solution#!/usr/bin/sh
if [ `/usr/bin/ls -ldi . | awk '{ print $1}'` = 2 ]
then
echo This is a mount point
else
echo This is not a mount point
fi
Each filesystem has it's own *root* directory. All root directories have the inode number 2 :-)
Andy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2001 11:18 PM
02-22-2001 11:18 PM
Re: checking mount point directory
That's by far the most elegant solution !! You deserve at least 20 (or more) for that one.
It's surprising that no one else even thought about that one...
You kicked our a$@es !!
8-(
Good show !
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2001 12:24 AM
02-23-2001 12:24 AM
Re: checking mount point directory
Now, we can go far away:
Find / -inum 2
Jim: Following your Philosofy you must add /SD_CDROM, /cdrom, /tmp_mnt ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2001 06:04 AM
02-26-2001 06:04 AM
Re: checking mount point directory
I thank everybody for your help.
I agree with Dan: Andy Monks suggested the most elegant solution.
I'll try to post other interesting questions...