Attributes not available in udev

udev

I'm attempting to write a udev rule for a USB device, however I'm having trouble matching the ATTRS{*} attributes in my rules. After a little debugging using udevadm info, I've found that none of my devices are showing any attributes.

When I run udevadm info -a for the root volume on my linux server, I get this:

  looking at device '/devices/vbd-768/block/xvda':
    KERNEL=="xvda"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{ro}=="0"
    ATTR{size}=="83886080"
    ATTR{stat}=="  717683    43803 15924796   381200  8002096  5757360 169243664  6994333        0   635530  7372343"
    ATTR{range}=="16"
    ATTR{discard_alignment}=="0"
    ATTR{ext_range}=="16"
    ATTR{alignment_offset}=="0"
    ATTR{inflight}=="       0        0"
    ATTR{removable}=="0"
    ATTR{capability}=="10"

However, when I run it on my laptop, I get this:

  looking at device '/devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda':
    KERNEL=="sda"
    SUBSYSTEM=="block"
    DRIVER==""

This occurs for any device. I can't seem to get ATTR{*} variables for any device on my system. What might be causing this issue?

Note: I'm running Arch Linux, stock kernel, up to date as of this post.

Best Answer

I'm wondering that you're viewing the correct entry in udevadm.

You're accessing /devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda on the laptop, which is very different from the /devices/vbd-768/block/xvda accessed on the server.

If you interest is in disks I would suggest looking it up by bus ID.


You can find the disk's bus ID using lsblk -S. There should be 7 rows, the first two are all you care about: NAME and HCTL. NAME indicated the drive name (such as sda) and HCTL indicates the BUS id (such as 2:0:0:0).

Now use this bus ID when looking up with udevadm

udevadm info --path=/sys/bus/scsi/devices/[bus ID] -a


When I did this one of the output groups was for something like your /devices/vbd-768/block/xvda, as well as the ATTRS. It seems the path you specify here is only for a subset of the drive's info.

Related Question