The Haus

Wednesday, September 27, 2006

New udev Rules

I spent the better part of last night trying to convert my old udev rules for my USB drive and my 8-in-1 card reader to work with the version of udev in Slackware 11.0 RC5. Somewhere along the way, they decided to make significant changes to the udev rules format. Hopefully they will stabilize now so they don't have to do anything stupid. Unfortunately Google searches were only turning up old information. Here's what I ended up with. I stored it in 10-local.rules in /etc/udev/rules.d/:

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

# USB drive
BUS=="scsi", KERNEL=="sd*", SYSFS{vendor}=="OTi", SYSFS{model}=="Flash Disk", NAME="%k", SYMLINK+="usbdrive"

Linux treats the four slots on the card reader as if they were separate SCSI drives. I only use Compact Flash and Secure Digital cards, so those are the only rules I wrote. The BUS, ID, and SYSFS{model} identify the slot. The NAME and OPTIONS create the nodes for the slots. The OPTIONS line is necessary because for whatever reason, the card's information is stored on the first partition. In the first rule, for example, this creates nodes for /dev/compactflash[1-15]. I only have to use /dev/compactflash1.

The USB drive rule is completely reworked. If I just looked for the model and vendor and then created the node with NAME, it wouldn't work. Basically it was creating a node for /dev/sg4 instead of /dev/sde. The way the rule above works is that it just creates a symbolic link called /dev/usbdrive to /dev/sde. So why use the rule instead of just adding /dev/sde to the fstab? Because if I would get rid of my card reader, for example, the device would become /dev/sda instead. This way /dev/usbdrive will always point to the right place, regardless of how many or few SCSI devices I have. It will Just Work.

No Old News

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).