Моя цель - делать разные вещи, когда подключено USB-устройство. Я узнал путь к ядру к моей флешке, когда подключил

/devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0/host0/target0:0:0/0:0:0:0/block/sda

Теперь я могу бежать

udevadm info -a -p /devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0/host0/target0:0:0/0:0:0:0/block/sda

что дает мне

Udevadm info 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 '//devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0/host0/target0:0:0/0:0:0:0/block/sda':
    KERNEL=="sda"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{SUBSYSTEM}=="block"
    ATTR{DEVTYPE}=="disk"
    ATTR{MAJOR}=="8"
    ATTR{MINOR}=="0"
    ATTR{USEC_INITIALIZED}=="70123316226"
    ATTR{ID_VENDOR}=="SanDisk"
    ATTR{ID_VENDOR_ENC}=="SanDisk\x20"
    ATTR{ID_VENDOR_ID}=="0781"
    ATTR{ID_MODEL}=="Ultra_Fit"
    ATTR{ID_MODEL_ENC}=="Ultra\x20Fit\x20\x20\x20\x20\x20\x20\x20"
    ATTR{ID_MODEL_ID}=="5583"
    ATTR{ID_REVISION}=="1.00"
    ATTR{ID_SERIAL}=="SanDisk_Ultra_Fit_4C530123260812112220-0:0"
    ATTR{ID_SERIAL_SHORT}=="4C530123260812112220"
    ATTR{ID_TYPE}=="disk"
    ATTR{ID_INSTANCE}=="0:0"
    ATTR{ID_BUS}=="usb"
    ATTR{ID_USB_INTERFACES}==":080650:"
    ATTR{ID_USB_INTERFACE_NUM}=="00"
    ATTR{ID_USB_DRIVER}=="usb-storage"
    ATTR{ID_PATH}=="pci-0000:00:14.0-usb-0:2:1.0-scsi-0:0:0:0"
    ATTR{ID_PATH_TAG}=="pci-0000_00_14_0-usb-0_2_1_0-scsi-0_0_0_0"
    ATTR{ID_FS_UUID}=="9C89-53D7"
    ATTR{ID_FS_UUID_ENC}=="9C89-53D7"
    ATTR{ID_FS_VERSION}=="FAT32"
    ATTR{ID_FS_TYPE}=="vfat"
    ATTR{ID_FS_USAGE}=="filesystem"
    ATTR{mount_options}=="noatime,utf8,gid=100,umask=002"
    ATTR{dir_name}=="usbhd-sda"
    ATTR{TAGS}==":systemd:"

  looking at parent device '//devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0/host0/target0:0:0/0:0:0:0':
    KERNELS=="0:0:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS=="sd"
    ATTRS{SUBSYSTEM}=="scsi"
    ATTRS{DRIVER}=="sd"
    ATTRS{DEVTYPE}=="scsi_device"
    ATTRS{MODALIAS}=="scsi:t-0x00"

  looking at parent device '//devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0/host0/target0:0:0':
    KERNELS=="target0:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS==""
    ATTRS{SUBSYSTEM}=="scsi"
    ATTRS{DEVTYPE}=="scsi_target"

  looking at parent device '//devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0/host0':
    KERNELS=="host0"
    SUBSYSTEMS=="scsi"
    DRIVERS==""
    ATTRS{SUBSYSTEM}=="scsi"
    ATTRS{DEVTYPE}=="scsi_host"

  looking at parent device '//devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0':
    KERNELS=="2-2:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb-storage"
    ATTRS{SUBSYSTEM}=="usb"
    ATTRS{DRIVER}=="usb-storage"
    ATTRS{DEVTYPE}=="usb_interface"
    ATTRS{PRODUCT}=="781/5583/100"
    ATTRS{TYPE}=="0/0/0"
    ATTRS{INTERFACE}=="8/6/80"
    ATTRS{MODALIAS}=="usb:v0781p5583d0100dc00dsc00dp00ic08isc06ip50in00"
    ATTRS{USEC_INITIALIZED}=="70122189776"
    ATTRS{ID_VENDOR_FROM_DATABASE}=="SanDisk Corp."
    ATTRS{ID_MODEL_FROM_DATABASE}=="Ultra Fit"

  looking at parent device '//devices/pci0000:00/0000:00:14.0/usb2/2-2':
    KERNELS=="2-2"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{SUBSYSTEM}=="usb"
    ATTRS{DRIVER}=="usb"
    ATTRS{DEVTYPE}=="usb_device"
    ATTRS{PRODUCT}=="781/5583/100"
    ATTRS{TYPE}=="0/0/0"
    ATTRS{BUSNUM}=="002"
    ATTRS{DEVNUM}=="029"
    ATTRS{MAJOR}=="189"
    ATTRS{MINOR}=="156"
    ATTRS{USEC_INITIALIZED}=="70122175758"
    ATTRS{ID_VENDOR}=="SanDisk"
    ATTRS{ID_VENDOR_ENC}=="SanDisk"
    ATTRS{ID_VENDOR_ID}=="0781"
    ATTRS{ID_MODEL}=="Ultra_Fit"
    ATTRS{ID_MODEL_ENC}=="Ultra\x20Fit"
    ATTRS{ID_MODEL_ID}=="5583"
    ATTRS{ID_REVISION}=="0100"
    ATTRS{ID_SERIAL}=="SanDisk_Ultra_Fit_4C530123260812112220"
    ATTRS{ID_SERIAL_SHORT}=="4C530123260812112220"
    ATTRS{ID_BUS}=="usb"
    ATTRS{ID_USB_INTERFACES}==":080650:"
    ATTRS{ID_VENDOR_FROM_DATABASE}=="SanDisk Corp."
    ATTRS{ID_MODEL_FROM_DATABASE}=="Ultra Fit"

  looking at parent device '//devices/pci0000:00/0000:00:14.0/usb2':
    KERNELS=="usb2"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{SUBSYSTEM}=="usb"
    ATTRS{DRIVER}=="usb"
    ATTRS{DEVTYPE}=="usb_device"
    ATTRS{PRODUCT}=="1d6b/3/420"
    ATTRS{TYPE}=="9/0/3"
    ATTRS{BUSNUM}=="002"
    ATTRS{DEVNUM}=="001"
    ATTRS{MAJOR}=="189"
    ATTRS{MINOR}=="128"
    ATTRS{USEC_INITIALIZED}=="1693784"
    ATTRS{ID_VENDOR}=="Linux_4.20.6-arch1-1-ARCH_xhci-hcd"
    ATTRS{ID_VENDOR_ENC}=="Linux\x204.20.6-arch1-1-ARCH\x20xhci-hcd"
    ATTRS{ID_VENDOR_ID}=="1d6b"
    ATTRS{ID_MODEL}=="xHCI_Host_Controller"
    ATTRS{ID_MODEL_ENC}=="xHCI\x20Host\x20Controller"
    ATTRS{ID_MODEL_ID}=="0003"
    ATTRS{ID_REVISION}=="0420"
    ATTRS{ID_SERIAL}=="Linux_4.20.6-arch1-1-ARCH_xhci-hcd_xHCI_Host_Controller_0000:00:14.0"
    ATTRS{ID_SERIAL_SHORT}=="0000:00:14.0"
    ATTRS{ID_BUS}=="usb"
    ATTRS{ID_USB_INTERFACES}==":090000:"
    ATTRS{ID_VENDOR_FROM_DATABASE}=="Linux Foundation"
    ATTRS{ID_MODEL_FROM_DATABASE}=="3.0 root hub"
    ATTRS{ID_PATH}=="pci-0000:00:14.0"
    ATTRS{ID_PATH_TAG}=="pci-0000_00_14_0"
    ATTRS{ID_FOR_SEAT}=="usb-pci-0000_00_14_0"
    ATTRS{TAGS}==":seat:"

  looking at parent device '//devices/pci0000:00/0000:00:14.0':
    KERNELS=="0000:00:14.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="xhci_hcd"
    ATTRS{SUBSYSTEM}=="pci"
    ATTRS{DRIVER}=="xhci_hcd"
    ATTRS{PCI_CLASS}=="C0330"
    ATTRS{PCI_ID}=="8086:9D2F"
    ATTRS{PCI_SUBSYS_ID}=="17AA:224F"
    ATTRS{PCI_SLOT_NAME}=="0000:00:14.0"
    ATTRS{MODALIAS}=="pci:v00008086d00009D2Fsv000017AAsd0000224Fbc0Csc03i30"
    ATTRS{USEC_INITIALIZED}=="1690169"
    ATTRS{ID_PCI_CLASS_FROM_DATABASE}=="Serial bus controller"
    ATTRS{ID_PCI_SUBCLASS_FROM_DATABASE}=="USB controller"
    ATTRS{ID_PCI_INTERFACE_FROM_DATABASE}=="XHCI"
    ATTRS{ID_VENDOR_FROM_DATABASE}=="Intel Corporation"
    ATTRS{ID_MODEL_FROM_DATABASE}=="Sunrise Point-LP USB 3.0 xHCI Controller"

  looking at parent device '//devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

Затем я написал простое правило udev:

tim@x1carbon ~> cat /etc/udev/rules.d/10-rule.rules
 SUBSYSTEMS=="usb",ACTION=="add", ATTRS{ID_SERIAL}=="SanDisk_Ultra_Fit_4C530123260812112220", RUN+="/usr/bin/touch /home/tim/test.txt"⏎
tim@x1carbon ~>

И запустил udevadm control -R чтобы перезагрузить udev. Когда я сейчас тестирую с

udevadm test /devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0/host0/target0:0:0/0:0:0:0/block/sda

Мое правило появляется, но когда я подключаю свое устройство, ничего не происходит. Кто-нибудь может мне помочь?

0