[lfs-support] udev custom rules for duplicate usb devices

Thanos Baloukas baloukasthan at sch.gr
Sat Feb 4 07:20:48 PST 2012


Hi
I'm trying to write custom udev rules to create persistent symlinks
for my usb stick and card reader. The first pluged gets /dev/sda and
the second /dev/sdb. I followed the instructions in
http://www.linuxfromscratch.org/lfs/view/stable/chapter07/symlinks.html
and tried many more (DRIVER="usb-storage",  DRIVER="ums-realtek",
SUBSYSTEM=="block", ACTION=="add"....) with no success.

cat /etc/udev/rules.d/83-duplicate_devs.rules

KERNEL=="sd*", ATTRS{ID_VENDOR}=="Generic-", ATTRS{ID_MODEL}=="Multi-Card", SYMLINK+="card_reader"
KERNEL=="sd*", ATTRS{ID_VENDOR}=="Kingston", ATTRS{ID_MODEL}=="DT_R500", SYMLINK+="usb_stick"

I tried renaming to 11-duplicate_devs.rules
At the moment I test booting having the devices pluged, until the symlinks
to be created and then add ACTION=="add" rule

For the usb stick:
udevadm info --query=all --path=/sys/block/sda
P: 
/devices/pci0000:00/0000:00:03.3/usb1/1-3/1-3:1.0/host0/target0:0:0/0:0:0:0/block/sda
N: sda
S: disk/by-id/usb-Kingston_DT_R500_0018F3D97163BBB1114800E2-0:0
S: disk/by-path/pci-0000:00:03.3-usb-0:3:1.0-scsi-0:0:0:0
E: UDEV_LOG=3
E: 
DEVPATH=/devices/pci0000:00/0000:00:03.3/usb1/1-3/1-3:1.0/host0/target0:0:0/0:0:0:0/block/sda
E: MAJOR=8
E: MINOR=0
E: DEVNAME=/dev/sda
E: DEVTYPE=disk
E: SUBSYSTEM=block
E: ID_VENDOR=Kingston
E: ID_VENDOR_ENC=Kingston
E: ID_VENDOR_ID=0951
E: ID_MODEL=DT_R500
E: ID_MODEL_ENC=DT\x20R500\x20\x20\x20\x20\x20\x20\x20\x20\x20
E: ID_MODEL_ID=1654
E: ID_REVISION=PMAP
E: ID_SERIAL=Kingston_DT_R500_0018F3D97163BBB1114800E2-0:0
E: ID_SERIAL_SHORT=0018F3D97163BBB1114800E2
E: ID_TYPE=disk
E: ID_INSTANCE=0:0
E: ID_BUS=usb
E: ID_USB_INTERFACES=:080650:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_DRIVER=usb-storage
E: ID_PATH=pci-0000:00:03.3-usb-0:3:1.0-scsi-0:0:0:0
E: ID_PATH_TAG=pci-0000_00_03_3-usb-0_3_1_0-scsi-0_0_0_0
E: ID_PART_TABLE_TYPE=dos
E: 
DEVLINKS=/dev/disk/by-id/usb-Kingston_DT_R500_0018F3D97163BBB1114800E2-0:0 
/dev/disk/by-path/pci-0000:00:03.3-usb-0:3:1.0-scsi-0:0:0:0

For the card reader:
udevadm info --query=all --path=/sys/block/sdb
P: 
/devices/pci0000:00/0000:00:03.3/usb1/1-5/1-5:1.0/host1/target1:0:0/1:0:0:0/block/sdb
N: sdb
S: disk/by-id/usb-Generic-_Multi-Card_20060413092100000-0:0
S: disk/by-path/pci-0000:00:03.3-usb-0:5:1.0-scsi-0:0:0:0
E: UDEV_LOG=3
E: 
DEVPATH=/devices/pci0000:00/0000:00:03.3/usb1/1-5/1-5:1.0/host1/target1:0:0/1:0:0:0/block/sdb
E: MAJOR=8
E: MINOR=16
E: DEVNAME=/dev/sdb
E: DEVTYPE=disk
E: SUBSYSTEM=block
E: ID_VENDOR=Generic-
E: ID_VENDOR_ENC=Generic-
E: ID_VENDOR_ID=0bda
E: ID_MODEL=Multi-Card
E: ID_MODEL_ENC=Multi-Card\x20\x20\x20\x20\x20\x20
E: ID_MODEL_ID=0158
E: ID_REVISION=1.00
E: ID_SERIAL=Generic-_Multi-Card_20060413092100000-0:0
E: ID_SERIAL_SHORT=20060413092100000
E: ID_TYPE=disk
E: ID_INSTANCE=0:0
E: ID_BUS=usb
E: ID_USB_INTERFACES=:080650:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_DRIVER=ums-realtek
E: ID_PATH=pci-0000:00:03.3-usb-0:5:1.0-scsi-0:0:0:0
E: ID_PATH_TAG=pci-0000_00_03_3-usb-0_5_1_0-scsi-0_0_0_0
E: ID_PART_TABLE_TYPE=dos
E: 
DEVLINKS=/dev/disk/by-id/usb-Generic-_Multi-Card_20060413092100000-0:0 
/dev/disk/by-path/pci-0000:00:03.3-usb-0:5:1.0-scsi-0:0:0:0

The output of udevadm test /sys/block/sd{a,b} is here: 
http://pastebin.ca/2109689

Thanks
Thanos

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxfromscratch.org/pipermail/lfs-support/attachments/20120204/a78d8285/attachment.html>


More information about the lfs-support mailing list