The Haus

Monday, March 7, 2005

Messing with udev

Since I upgraded to the 2.6.10 kernel (I'm now using 2.6.11), I had problems getting my card reader to work. The problem turned out to be a new driver called "ub" which will replace "usb-storage". It will allow USB devices to be dealt with without having to treat them as if they were SCSI devices. It sounds good in theory, but practically it's not quite there yet. I ditched it and went back to the more familiar usb-storage.

Initally I thought I could solve the problem by moving to udev instead of using a static /dev filesystem. While that did not turn out to be the case, I did learn a lot. I began to realize the power that udev offers. Unfortunately, it is very poorly documented right now. Basically udev works with hotplug to automatically create device nodes as needed. The really cool thing is that you can create rules of your own choosing. Let me give you some examples from my /etc/udev/rules.d/10-local.rules file.

# Card reader
BUS="scsi", ID="*:0", SYSFS{model}="STORAGE DEVICE ", NAME{all_partitions}="compactflash"
BUS="scsi", ID="*:2", SYSFS{model}="STORAGE DEVICE ", NAME{all_partitions}="securedigital"

# USB drive
BUS="scsi", SYSFS{vendor}="OTi", SYSFS{model}="Flash Disk", NAME="usbdrive"

The first two rules are for my card reader. It looks on the SCSI bus for a product that calls itself "STORAGE DEVICE " (which is how my SanDisk reader reports itself). It then sets up /dev/compactflash[1-15] for it (I need it to create all the extra devices because the cards use the first partition for some reason). So I can insert a compact flash card and mount /dev/compactflash1 and away I go! I don't have to worry about device numbers changing since I'm looking for the actual name of the device. The second rule does the same thing for my secure digital slot. The third rule is for my USB drive. My SimpleTech drive reports itself as "OTi". When that is plugged in, udev/hotplug creates /dev/usbdrive. Pretty slick, actually. It also seems to have matured quite a bit and isn't quite as flaky as it once was.

By the way, to find out the vendor name, etc., look under /sys/bus/scsi/devices/ to see how things are being reported. I really hope someone is working on better documentation for all of this. It's quite sparse right now. I spent many hours Googling trying to pick this all up.

News for 03/07/2005

Recent Headlines

January 5, 2015: It Returns!
August 10, 2007: SCO SUCKS IT DOWN!
July 5, 2007: Slackware 12.0 Released
May 20, 2007: PhpBB 3.0 RC 1 Released
February 2, 2007: DOOM3 1.31 Patch

January 27, 2007: Join the World Community Grid
January 17, 2007: Flash Player 9 for Linux
December 30, 2006: Darkness over Daggerford 1.2
December 19, 2006: Pocket Tunes 4.0 Released
December 9, 2006: WRT54G 1.01.1 Firmware OK with Linux/Mac

All original information on this website is copyright © TheHaus.Net, 1999-2005. The use of original images, text, and/or code from this website without expressed written consent is prohibited. The authors of this site cannot be held responsible for any damage, real or imagined, which comes from the use of information presented on this site. All trademarks used are the properties of their respective owners. This site is not to be used as a floatation device (but if you try, I want a video tape of it).