[Techtalk] checking mounts

Sarah Newman newmans at sonic.net
Sat Sep 26 14:51:07 UTC 2009


df | grep "/dev/mmcblk1p2"; echo $?

The variable $? which is the exit code Should be 0 on success and 1 on 
failure

Why df and not mount:

#mount
rootfs on / type rootfs (rw)
/dev/root on /mnt/initfs type jffs2 (ro)
none on /mnt/initfs/proc type proc (rw)
none on /mnt/initfs/sys type sysfs (rw)
none on /mnt/initfs/tmp type tmpfs (rw)
/dev/mmcblk0p2 on / type ext3 (rw,noatime,data=ordered)
none on /tmp type tmpfs (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
none on /dev type tmpfs (rw)
devpts on /dev/pts type devpts (rw)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
/dev/mmcblk1p1 on /media/mmc1 type vfat 
(rw,nosuid,nodev,uid=29999,fmask=0022,dask=0022,codepage=cp437,iocharset=iso8859-1,utf8)

#df
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/mmcblk1p2            4096      2316      1780  57% /mnt/initfs
none                       512       120       392  23% /mnt/initfs/tmp
/dev/mmcblk0p2          484186    349387    109798  76% /
none                       512       120       392  23% /tmp
none                      1024        60       964   6% /dev
tmpfs                     1024         0      1024   0% /dev/shm
/dev/mmcblk1p1         7225136   4961636   2263500  69% /media/mmc1

Note how in mount it is  "/dev/root" on "/mnt/initfs" and in df it is 
"/dev/mmcblk1p2"  on /mnt/initfs .  I've had other weird things with 
what the mount partition is called.


Miriam English wrote:
> Hi folks,
> 
> I want to make a shell script check whether a device is mounted or not.
> 
> Anyone know how to do this? There has to be a way...
> 
> It is not terribly important, just a script for myself to make my own 
> life easier, but it is starting to really bug me and if I don't ask 
> someone I just know I'll end up wasting hours and hours looking for the 
> stupid thing. :)
> 
> Thanks,
> 
> 	- Miriam
> 


More information about the Techtalk mailing list