[NTLUG:Discuss] Bash script way to tell if a filesystem is mounted
Patrick R. Michaud
pmichaud at pobox.com
Sat May 29 04:03:16 CDT 2010
On Sat, May 29, 2010 at 03:50:42AM -0500, Ralph Green wrote:
> More detailed version next. Let's say I want to know if a filesystem
> is mounted at /cifs_shares/server2.
Perhaps:
PARENTID=$( stat -f --format='%i' /cifs_shares )
FILESYSID=$( stat -f --format='%i' /cifshares/server2 )
if [ $PARENTID == $FILESYSID ]
then
echo "/cifshares/server2 is not mounted"
else
fi
"stat -f" means you're asking for filesystem information.
The '%i' format returns the filesystem identifier for the
given file/directory. If a directory and its parent
have the same filesystem identifier, then that directory
is not a filesystem mount point.
Pm
More information about the Discuss
mailing list