some question about mdev

Denys Vlasenko vda.linux at googlemail.com
Sun May 23 19:52:51 UTC 2010


On Sunday 23 May 2010 10:23, loody wrote:
> hi Denys:
> 
> 2010/5/23 Denys Vlasenko <vda.linux at googlemail.com>:
> > On Saturday 22 May 2010 14:33, loody wrote:
> >> Dear all:
> >> I use mdev to handle hotplug event under linux.
> >> it runs fine when I plug/unplug usb flash.
> >> But it has some problem when I plug/unplug usb HD.
> >> Below are my partions I get when I plug my USB HD.
> >>
> >> # cat /proc/partitions
> >> major minor  #blocks  name
> >>
> >>    8        0    1972224 sda
> >>    8        1    1970546 sda1
> >>    8       16  156290904 sdb
> >>    8       17          1 sdb1
> >>    8       21  156280288 sdb5
> >> #
> >>
> >> and below is my mdev.conf
> >> sd[a-zA-Z][0-9]+ 0:0 0660 * /usr/bin/autoscript.sh $MDEV $LABEL
> >>
> >> As you can see, mdev will pass sdb1 to /usr/bin/autoscript.sh for mounting.
> >> But the partion cannot be mount.( from the information in
> >> /proc/partitions, it seems some place for data saving.)
> >
> > Please show autoscript.sh, exact mount command parameters and its error message.
> > Also, what "cat /proc/filesystems" says? What is your busybox version?
> >
> > --
> > vda
> >
> 
> I guess my problem comes from 2 parts:
> 1. Mdev will pass every partition to autorun.sh for mounting.
> But in my case, there is a super block partition. ( like the extension
> partition)
> 2. when mdev pass different format partitions to autorun.sh,
> autorun.sh should use different mount parameters for mounting. But it
> doesn't.
> 
> my questions are:
> 1. how could I stop mdev to pass the superblock partition to autorun.sh
> 2. is there additional paramter that mdev can pass to shell such that
> they can know the format is different?
> BR,
> miloody
> 
> below is my autorun.sh
> 
> #! /bin/sh
> if [ "$1" == "" ]; then
> echo "parameter is none" > /tmp/error.txt
> exit 1
> fi
> mounted=`mount | grep $1 | cut -d ' ' -f 3`
> 
> if [ ! -z $mounted ]; then
>         echo "R$mounted" >> /tmp/usbmnt.log
>         echo "R$mounted" > /tmp/fifo.1
>         if ! umount "$mounted"; then
>         exit 1
>         fi

umount "$mounted" || exit 1

is a much less verbose method to do the same...

>         if ! rmdir "$mounted"; then
>         exit 1
>         fi
> else
>         if [ -z "$2" ];then
>                 dir=$1
>         else
>                 dir=$2
>         fi
>         if ! mkdir -p "/media/$dir"; then
>         exit 1
>         fi
>         if ! mount -o codepage=437,iocharset=iso8859-1,utf8 "/dev/$1"
> "/media/$dir"; then

Befire doing this, you might want to check that the device
actually contains some filesystem. For example, using blkid:

3 blkid /dev/sda; echo $?
2
# blkid /dev/sda1; echo $?
/dev/sda1: UUID="E051-DF71" TYPE="vfat"
0

As you see, you can parse blkid output and then use
filesystem-specific mount options.

-- 
vda


More information about the busybox mailing list