[NTLUG:Discuss] Bash script way to tell if a filesystem is mounted

Patrick R. Michaud pmichaud at pobox.com
Sat May 29 12:08:37 CDT 2010


On Sat, May 29, 2010 at 11:07:48AM -0500, Hank Ivy wrote:
> On Saturday 29 May 2010 09:28 am Ralph Green wrote:
> >  If a directory and its parent  
> >  have the same filesystem identifier, then that directory
> >  is not a filesystem mount point.
> 
> What will happen if you have multiple levels of mount points?
> 
> For Example (in /etc/fstab):
> /dev/md17 /home2 ... 3
> /dev/md18 /home2/userx ... 4
> 
> The 3 and the 4 control the order of the mounts.
> If neither file system is mounted, will the return values be the same?

Presumably if /home2 isn't mounted, then /home2/userx (the mountpoint)
doesn't exist.  Unless of course someone has also created /home2/userx 
in /home2 of the root filesystem, which then gets masked when /home2
is mounted.

But yes, what I said above still applies -- if a directory (/home2/userx)
and its parent (/home2) have the same file system identifier, then
the directory is not a filesystem mount point.  So if neither /home2
nor /home2/userx are mounted, then /home2 will have the same filesystem
identifier as /, and /home2/userx will have the same filesystem identifier
as /home2 .

Pm



More information about the Discuss mailing list