0

im trying to create a udev symlink rule:

Here is what i have written so far which doesnt seem to work:

ACTION=="add", SUBSYSTEM=="block", ATTR{size}=="60626944", ATTRS{model}=="USB DISK 2.0    ", SYMLINK+="integralusb"

The device i am trying to create a SYMlink on upon plugging in is a USB thumb-drive. Here is the output of udevadm info --query=all /dev/sdb

 udevadm info --query=all /dev/sdb
P: /devices/pci0000:00/0000:00:10.0/usb2/2-3/2-3:1.0/host2/target2:0:0/2:0:0:0/block/sdb
N: sdb
L: 0
S: disk/by-id/usb-_USB_DISK_2.0_900074BF37B00367-0:0
S: disk/by-path/pci-0000:00:10.0-usb-0:3:1.0-scsi-0:0:0:0
E: DEVPATH=/devices/pci0000:00/0000:00:10.0/usb2/2-3/2-3:1.0/host2/target2:0:0/2:0:0:0/block/sdb
E: DEVNAME=/dev/sdb
E: DEVTYPE=disk
E: MAJOR=8
E: MINOR=16
E: SUBSYSTEM=block
E: USEC_INITIALIZED=5783303806
E: ID_VENDOR_ENC=\x20\x20\x20\x20\x20\x20\x20\x20
E: ID_VENDOR_ID=26bd
E: ID_MODEL=USB_DISK_2.0
E: ID_MODEL_ENC=USB\x20DISK\x202.0\x20\x20\x20\x20
E: ID_MODEL_ID=9917
E: ID_REVISION=PMAP
E: ID_SERIAL=_USB_DISK_2.0_900074BF37B00367-0:0
E: ID_SERIAL_SHORT=900074BF37B00367
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:10.0-usb-0:3:1.0-scsi-0:0:0:0
E: ID_PATH_TAG=pci-0000_00_10_0-usb-0_3_1_0-scsi-0_0_0_0
E: ID_PART_TABLE_TYPE=dos
E: DEVLINKS=/dev/disk/by-id/usb-_USB_DISK_2.0_900074BF37B00367-0:0 /dev/disk/by-path/pci-0000:00:10.0-usb-0:3:1.0-scsi-0:0:0:0
E: TAGS=:systemd:

I have no idea what i have done wrong, i am new to creating udev rules but this looks okay to me.

8
  • It looks like you used something like udevadm info --attribute-walk /dev/sdb to extract the matching part of your udev rule. If not, please check if there are any inadvertant typos. If you debug your rule e.g. by replacing the SYMLINK directive with something like RUN="/usr/bin/touch /tmp/rule_processed.txt", do you see that this temporary file is created when you add the device?
    – AdminBee
    Nov 6, 2019 at 11:43
  • Or udevadm info -a /dev/sdb, this shows ATTR{size}=="468862128" for me, with sda. To debug also use "udevadm monitor ...". (I found my RUNs only failed in journalctl ;).
    – user373503
    Nov 6, 2019 at 12:11
  • @AdminBee so what would you reccomend using to get info on the device in order to write the rule correctly?
    – programmer
    Nov 6, 2019 at 12:49
  • @rastafile so what should I do?
    – programmer
    Nov 6, 2019 at 12:49
  • 1
    Actually, using udevadm info --attribute-walk is the correct approach to get the necessary info for writing a udev rule. My first comment was only meant in case you had obtained the attribute values by some other means so that you could check with the output of udevadm if maybe there is some trivial typo. BTW, does journalctl show any udev error messages when you plug in the device (which might hint at syntax errors or similar)?
    – AdminBee
    Nov 6, 2019 at 13:05

2 Answers 2

0

ATTRS{model}=="USB DISK 2.0 "

I think there is too much whitspace here. This is a string match.

Here an example from 50-default...rules, wildcards work also:

ENV{ID_USB_INTERFACES}=="*:0701??:*"

1
  • After days of struggle and testing this rule I figured out why it didn't work, let's just say udev rules strictly only follow the output of udevadm info --attribute-walk. In my rule I added "ACTION="add", this wasnt specified in the output of udevadm so it didn't work.
    – programmer
    Nov 8, 2019 at 13:38
0

For me the answer was: change your rule from ACTION=="add" to ACTION=="add|change".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .