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

Leroy Tennison leroy_tennison at prodigy.net
Sun May 30 21:53:18 CDT 2010


Ralph Green wrote:
> Howdy,
>   I thought I had the script all working and then I ran across something
> like what you found.  When I run the stat command on a system with jfs,
> I always get a value of 0.  On xfs and ext2, everything works.  I don't
> have any systems with ext3.  Can anyone verify if a stat like Leroy used
> returns a non-zero value on ext3?  I would not ever setup a system with
> ext3 or ext4, but I know I should be prepared if I come across one and
> need to do diagnostics.
>  I am going to redo my script to use Chris' idea of grepping /etc/mtab
> or /proc/mounts.
> Good night,
> Ralph
>
> On Sat, 2010-05-29 at 16:24 -0500, Leroy Tennison wrote:
>   
>> [root at localhost ~]# stat -f --format='%i' /boot
>> 0
>> [root at localhost ~]# stat -f --format='%i' /boot/grub
>> 0
>> [root at localhost ~]#
>>
>> Not only am I seeing a directory and it's parent with the same file 
>> system ID when it is a mount point,  both IDs are zero.  Just in case 
>>     
>
>   
>> Any idea what's wrong?
>>     
>
>
>
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss
>
>   
Well, I need to "add" to my reply.  Although my root (/) is ext3, /boot 
(= /dev/hda1) is ext2.  So, either root's being ext3 is a problem or 
stat doesn't work on ext2 on CentOS 5.4.  Previously I reported my 
version of stat, what are other people's versions?



More information about the Discuss mailing list