Skip to contentSkip to conversation

Writing udev Rules by Daniel Drake (dsd) Version 0.72

DISCUSSION Rick Pizzi 3 participants 3 messages Sep 18, 2007

lore
Share & tools
lore

Rick Pizzi

author
#0 lore raw

Hi,
I have been trying to follow subject Daniel Drakes instructions on how to have various devices on my Ubuntu Feisty system mount with persistent names. As an example the attached dmesgSDB file shows my 'U3 Cruzer Micro' as sdb. The udevSDB attached file shows the result of the command:
"*sudo udevinfo -a -p $(udevinfo -q path -n /dev/sdb)*". I note there is no *SYSFS *attributes only *ATTRS*. Also there is no place that *BUS="usb" *shows up, only *KERNELS=="4.4"*. I have cobbled up a rule attached as *10-local.rules* which, of course, does not work when I re-boot my computer. The attached file *udevtestSDB* mentions U3 Cruzer Micro so something is trying to work, I guess.

Can you help me by explaining what is going on here? Why doesn't udevinfo show information like Daniel's article shows? How do I use the attributes from *usbview*? Usbview shows information such as: Manufacturer: SanDisk Corporation, Product Id:5406 etc.

Thanks in advance for your help,

Rick P.

[ 4147.836000] sdb: Write Protect is off
[ 4147.836000] sdb: Mode Sense: 03 00 00 00
[ 4147.836000] sdb: assuming drive cache: write through
[ 4147.836000] SCSI device sdb: 4001422 512-byte hdwr sectors (2049 MB)
[ 4147.836000] sdb: Write Protect is off
[ 4147.836000] sdb: Mode Sense: 03 00 00 00
[ 4147.836000] sdb: assuming drive cache: write through
[ 4147.836000]  sdb: sdb1
[ 4147.840000] sd 3:0:0:0: Attached scsi removable disk sdb
[ 4147.840000] sd 3:0:0:0: Attached scsi generic sg2 type 0

Udevinfo starts with the device specified by the devpath and then walks up the chain of parent devices. It prints for every device found, all possible attributes in the udev rules key format. A rule to match, can be composed by the attributes of the device and the attributes from one single parent device.

looking at device '/block/sdb':

    KERNEL=="sdb"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{stat}=="     327      505      868      260        0        0        0        0        0      228      260"
    ATTR{size}=="4001422"
    ATTR{removable}=="1"
    ATTR{range}=="16"
    ATTR{dev}=="8:16"

looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb4/4-4/4-4:1.0/host3/target3:0:0/3:0:0:0':

    KERNELS=="3:0:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS=="sd"
    ATTRS{ioerr_cnt}=="0x1"
    ATTRS{iodone_cnt}=="0x2d6"
    ATTRS{iorequest_cnt}=="0x2d6"
    ATTRS{iocounterbits}=="32"
    ATTRS{timeout}=="30"
    ATTRS{state}=="running"
    ATTRS{rev}=="3.27"
    ATTRS{model}=="U3 Cruzer Micro "
    ATTRS{vendor}=="SanDisk "
    ATTRS{scsi_level}=="3"
    ATTRS{type}=="0"
    ATTRS{queue_type}=="none"
    ATTRS{queue_depth}=="1"
    ATTRS{device_blocked}=="0"
    ATTRS{max_sectors}=="240"

looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb4/4-4/4-4:1.0/host3/target3:0:0':

    KERNELS=="target3:0:0"
    SUBSYSTEMS==""
    DRIVERS==""

looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb4/4-4/4-4:1.0/host3':

    KERNELS=="host3"
    SUBSYSTEMS==""
    DRIVERS==""

looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb4/4-4/4-4:1.0':

    KERNELS=="4-4:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb-storage"
    ATTRS{modalias}=="usb:v0781p5406d0010dc00dsc00dp00ic08isc06ip50"
    ATTRS{bInterfaceProtocol}=="50"
    ATTRS{bInterfaceSubClass}=="06"
    ATTRS{bInterfaceClass}=="08"
    ATTRS{bNumEndpoints}=="02"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bInterfaceNumber}=="00"

looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb4/4-4':

    KERNELS=="4-4"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{serial}=="0000160EF172FFE1"
    ATTRS{product}=="U3 Cruzer Micro"
    ATTRS{manufacturer}=="SanDisk Corporation"
    ATTRS{maxchild}=="0"
    ATTRS{version}==" 2.00"
    ATTRS{devnum}=="5"
    ATTRS{speed}=="480"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceClass}=="00"
    ATTRS{bcdDevice}=="0010"
    ATTRS{idProduct}=="5406"
    ATTRS{idVendor}=="0781"
    ATTRS{bMaxPower}=="200mA"
    ATTRS{bmAttributes}=="80"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{configuration}==""

looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb4':

    KERNELS=="usb4"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{serial}=="0000:00:1d.7"
    ATTRS{product}=="EHCI Host Controller"
    ATTRS{manufacturer}=="Linux 2.6.20-16-generic ehci_hcd"
    ATTRS{maxchild}=="6"
    ATTRS{version}==" 2.00"
    ATTRS{devnum}=="1"
    ATTRS{speed}=="480"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bcdDevice}=="0206"
    ATTRS{idProduct}=="0000"
    ATTRS{idVendor}=="0000"
    ATTRS{bMaxPower}=="  0mA"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{configuration}==""

looking at parent device '/devices/pci0000:00/0000:00:1d.7':

    KERNELS=="0000:00:1d.7"
    SUBSYSTEMS=="pci"
    DRIVERS=="ehci_hcd"
    ATTRS{msi_bus}==""
    ATTRS{broken_parity_status}=="0"
    ATTRS{enable}=="1"
    ATTRS{modalias}=="pci:v00008086d000024CDsv00001028sd0000014Ebc0Csc03i20"
    ATTRS{local_cpus}=="ff"
    ATTRS{irq}=="11"
    ATTRS{class}=="0x0c0320"
    ATTRS{subsystem_device}=="0x014e"
    ATTRS{subsystem_vendor}=="0x1028"
    ATTRS{device}=="0x24cd"
    ATTRS{vendor}=="0x8086"

looking at parent device '/devices/pci0000:00':

    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

##BUS=="usb", ATTRS{serial}=="DEF1031F4402", ATTRS{manufacturer}=="Cypress Semiconductor", NAME{all-partitions}=="IOGEAR" KERNELS=="4-4",ATTRS{product}=="U3 Cruzer Micro", ATTRS{manufacturer}=="SanDisk Corporation", SYMLINK+="MICRO2GB"

parse_file: reading '/etc/udev/rules.d/00-init.rules' as rules file
parse_file: reading '/etc/udev/rules.d/05-options.rules' as rules file
parse_file: reading '/etc/udev/rules.d/10-local.rules' as rules file
parse_file: reading '/etc/udev/rules.d/20-names.rules' as rules file
parse_file: reading '/etc/udev/rules.d/25-dmsetup.rules' as rules file
parse_file: reading '/etc/udev/rules.d/25-iftab.rules' as rules file
parse_file: reading '/etc/udev/rules.d/30-cdrom_id.rules' as rules file
parse_file: reading '/etc/udev/rules.d/40-permissions.rules' as rules file
parse_file: reading '/etc/udev/rules.d/45-hplip.rules' as rules file
parse_file: reading '/etc/udev/rules.d/45-libgphoto2.rules' as rules file
parse_file: reading '/etc/udev/rules.d/45-libsane.rules' as rules file
parse_file: reading '/etc/udev/rules.d/50-xserver-xorg-input-wacom.rules' as rules file
parse_file: reading '/etc/udev/rules.d/60-libpisock.rules' as rules file
parse_file: reading '/etc/udev/rules.d/60-symlinks.rules' as rules file
parse_file: reading '/etc/udev/rules.d/65-persistent-input.rules' as rules file
parse_file: reading '/etc/udev/rules.d/65-persistent-storage.rules' as rules file
parse_file: reading '/etc/udev/rules.d/80-programs.rules' as rules file
parse_file: reading '/etc/udev/rules.d/85-alsa.rules' as rules file
parse_file: reading '/etc/udev/rules.d/85-brltty.rules' as rules file
parse_file: reading '/etc/udev/rules.d/85-hdparm.rules' as rules file
parse_file: reading '/etc/udev/rules.d/85-hplj10xx.rules' as rules file
parse_file: reading '/etc/udev/rules.d/85-hwclock.rules' as rules file
parse_file: reading '/etc/udev/rules.d/85-ifupdown.rules' as rules file
parse_file: reading '/etc/udev/rules.d/85-pcmcia.rules' as rules file
parse_file: reading '/etc/udev/rules.d/90-modprobe.rules' as rules file
parse_file: reading '/etc/udev/rules.d/95-hal.rules' as rules file
parse_file: reading '/etc/udev/rules.d/99-udevmonitor.rules' as rules file This program is for debugging only, it does not run any program, specified by a RUN key. It may show incorrect results, if rules
match against subsystem specfic kernel event variables.

main: looking at device '/block/sdb' from subsystem 'block'
udev_rules_get_name: add symlink 'MICRO2GB'
run_program: 'usb_id -x'
run_program: '/lib/udev/usb_id' (stdout) 'ID_VENDOR=SanDisk'
run_program: '/lib/udev/usb_id' (stdout) 'ID_MODEL=U3_Cruzer_Micro'
run_program: '/lib/udev/usb_id' (stdout) 'ID_REVISION=3.27'
run_program: '/lib/udev/usb_id' (stdout) 'ID_SERIAL=SanDisk_U3_Cruzer_Micro_0000160EF172FFE1-0:0'
run_program: '/lib/udev/usb_id' (stdout) 'ID_SERIAL_SHORT=0000160EF172FFE1'
run_program: '/lib/udev/usb_id' (stdout) 'ID_TYPE=disk'
run_program: '/lib/udev/usb_id' (stdout) 'ID_INSTANCE=0:0'
run_program: '/lib/udev/usb_id' (stdout) 'ID_BUS=usb'
run_program: '/lib/udev/usb_id' returned with status 0
udev_rules_get_name: add symlink 'disk/by-id/usb-SanDisk_U3_Cruzer_Micro_0000160EF172FFE1-0:0'
run_program: 'path_id /block/sdb'
run_program: '/lib/udev/path_id' (stdout) 'ID_PATH=pci-0000:00:1d.7-usb-0:4:1.0-scsi-0:0:0:0'
run_program: '/lib/udev/path_id' returned with status 0
udev_rules_get_name: add symlink 'disk/by-path/pci-0000:00:1d.7-usb-0:4:1.0-scsi-0:0:0:0'
udev_rules_get_name: no node name set, will use kernel name 'sdb'
udev_device_event: device '/block/sdb' already in database, cleanup
udev_node_add: creating device node '/dev/sdb', major = '8', minor = '16', mode = '0660', uid = '0', gid = '46'
udev_node_update_symlinks: update symlink 'MICRO2GB' of '/block/sdb'
udev_db_get_devices_by_name: no index directory '/dev/.udev/names/MICRO2GB': No such file or directory
update_link: found -1 devices with name 'MICRO2GB'
update_link: no reference left, remove 'MICRO2GB'
udev_node_update_symlinks: update symlink 'disk/by-id/usb-SanDisk_U3_Cruzer_Micro_0000160EF172FFE1-0:0' of '/block/sdb' udev_db_get_devices_by_name: found index directory '/dev/.udev/names/disk%2fby-id%2fusb-SanDisk_U3_Cruzer_Micro_0000160EF172FFE1-0:0'
update_link: found 1 devices with name 'disk/by-id/usb-SanDisk_U3_Cruzer_Micro_0000160EF172FFE1-0:0'
update_link: found '/block/sdb' for 'disk/by-id/usb-SanDisk_U3_Cruzer_Micro_0000160EF172FFE1-0:0'
update_link: compare (our own) priority of '/block/sdb' 0 >= 0
update_link: 'disk/by-id/usb-SanDisk_U3_Cruzer_Micro_0000160EF172FFE1-0:0' with target 'sdb' has the highest priority 0, create it
udev_node_update_symlinks: update symlink 'disk/by-path/pci-0000:00:1d.7-usb-0:4:1.0-scsi-0:0:0:0' of '/block/sdb' udev_db_get_devices_by_name: found index directory '/dev/.udev/names/disk%2fby-path%2fpci-0000:00:1d.7-usb-0:4:1.0-scsi-0:0:0:0'
update_link: found 1 devices with name 'disk/by-path/pci-0000:00:1d.7-usb-0:4:1.0-scsi-0:0:0:0'
update_link: found '/block/sdb' for 'disk/by-path/pci-0000:00:1d.7-usb-0:4:1.0-scsi-0:0:0:0'
update_link: compare (our own) priority of '/block/sdb' 0 >= 0
update_link: 'disk/by-path/pci-0000:00:1d.7-usb-0:4:1.0-scsi-0:0:0:0' with target 'sdb' has the highest priority 0, create it
main: run: 'socket:/org/freedesktop/hal/udev_event'
main: run: 'socket:/org/kernel/udev/monitor'

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#1 lore raw
Quoted 13 lines · Rick Pizzi

Hi,
I have been trying to follow subject Daniel Drakes instructions on how
to have various devices on my Ubuntu Feisty system mount with persistent names. As an example the attached dmesgSDB file shows my 'U3 Cruzer Micro' as sdb. The udevSDB attached file shows the result of the command:
"*sudo udevinfo -a -p $(udevinfo -q path -n /dev/sdb)*". I note there is no *SYSFS *attributes only *ATTRS*. Also there is no place that *BUS="usb" *shows up, only *KERNELS="4.4"*. I have cobbled up a rule attached as *10-local.rules* which, of course, does not work when I re-boot my computer. The attached file *udevtestSDB* mentions U3 Cruzer Micro so something is trying to work, I guess.

Quoted 4 lines

Can you help me by explaining what is going on here? Why doesn't udevinfo show information like Daniel's article shows? How do I use the attributes from *usbview*? Usbview shows information such as:
Manufacturer: SanDisk Corporation, Product Id:5406 etc.

I think this is closer to what you want -- note that the rule contents come from the udevinfo output. Also note that I didn't change the NAME of the device node assigned - that's just not a good idea IMHO.

SUBSYSTEMS="usb", \
ATTRS{serial}="0000160EF172FFE1", \
ATTRS{product}="U3 Cruzer Micro", \
ATTRS{manufacturer}="SanDisk Corporation", \
NAME="%k", SYMLINK+="MICRO2GB"

-RW

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#2 lore raw
In reply to Rick Pizzi
Quoted 10 lines · Robby Workman

I think this is closer to what you want -- note that the rule contents come from the udevinfo output. Also note that I didn't change the NAME of the device node assigned - that's just not a good idea IMHO.

SUBSYSTEMS="usb", \
ATTRS{serial}="0000160EF172FFE1", \
ATTRS{product}="U3 Cruzer Micro", \
ATTRS{manufacturer}="SanDisk Corporation", \
NAME="%k", SYMLINK+="MICRO2GB"

If you already consider changing NAME not a good idea I suggest to completely delete NAME=... from the rule. Then other rules intended to change NAME can do this. And the symlink will in every case point to the correct device. If NAME does not get set in any rule it still defaults to "%k".

Matthias

Signature · 10 lines
Matthias Schwarzott (zzam)

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel