[Techtalk] finding labels for mount or fstab for USB devices

Akkana Peck akkana at shallowsky.com
Sun Feb 15 13:23:01 EST 2004


Carla asks:
> >I was wondering what sort of /dev files USB storage devices get parked 
> >under.
> >Do they always go under /dev/sd*? How do you find out? Output samples
> >welcome. :)

Christina Zeeh answers with lots of good detail, then says:
> Which storage devices currently are assigned to which /dev files can be 
> seen somewhere in /proc (sorry, don't have access to my test machine 
> atm and can't remember the exact location).

/proc/scsi/usb-storage-*

Since my Vaio has a built-in memory stick that sometimes registers
and sometimes doesn't, so devices may show up as sda or sdb depending
on whether the stick already snarfed one device, at one point I wrote
a perl script to handle it automatically.  The script is too specific
to my particular devices to be of general use, but basically it loops
over $id doing:
  $procfile = "/proc/scsi/usb-storage-" . $id . "/" . $id;
  $scsidev = "/dev/sd" . chr(ord("a") + $id) . "1";
  $product = `grep Product $procfile`;
and then checking things like
  if ($product =~ /Memory Stick/)

Also, if I remove a device and then re-insert the same device (perhaps
because I shot two cards worth of pictures today), sometimes it gets
a new number and sometimes not (and occasionally it doesn't work at
all and I have to rmmod usb-storage and start over).  But typing
"eject /pix" instead of "umount /pix" when I unmount the first card
seems to cure this, even though eject always prints an error message.
I think hotplug is supposed to take care of this, but I've encountered
this on both redhat and debian.

The new udev package for 2.6 should make it easier to solve this
problem, though my understanding is that hotplug-type scripts will
still be needed to decide what gets mounted where.

	...Akkana


More information about the Techtalk mailing list