[svlug] usb device automounting on linux

Akkana Peck akkana at shallowsky.com
Mon Jun 4 14:26:11 PDT 2007

Brian J. Tarricone writes:
> On Mon, 4 Jun 2007 12:23:15 -0700 Akkana Peck wrote:
> >Creating the /dev/sdXX devices is normally handled by udev (but
> >sometimes with hal's help, depending on the distro and the device).
> HAL only reacts to the device plug/unplug.  udev or devfs always handles
> creating the device node -- or you can just have a static /dev tree,
> but that seems to be much less common these days.

There are a number of cases where udev won't create a device
without hal. For instance, if you have a Vaio with a built-in memory
stick reader, or a desktop with a built-in flash card reader (the
kind that has multiple slots for SD, CF, MS etc.), you're likely
to get sda, sdb, etc. devices at boot time. Now insert the card
from your camera. Udev doesn't keep checking and no event is fired,
so you still only have /dev/sda, not the /dev/sda1 you need.  If you
want to mount the card you have to do something to create /dev/sda1.

Add hal, and what happens is that hal runs a bunch of daemons
that poll the various buses on your system (USB, IDE CDROM, etc.)
asking "has anything changed in the last half-second?"
Insert your flash card, and half a second later one of several
/usr/lib/hal/hald-addon-storage daemons wakes up, polls and sees it,
and tells udev (probably by doing touch /dev/sda) to create /dev/sda1.

If you don't want hal polling your hardware all the time (I know
Gnome/KDE folks don't mind, but someone who runs icewm might be more
interested in such optimizations), the solutions are (a) touch
/dev/sda before trying to mount /dev/sda1, or (b) write a udev rule
to add "all_partitions" for any device of this type, so it creates
/dev/sda1 through /dev/sda15 initially.

    "Beginning GIMP: From Novice to Professional": http://gimpbook.com

More information about the svlug mailing list