udev-misc, little things regarding custom udev rules



<< BACK TO KBIN-STUFF



User created rules are located under /etc/udev/rules.d and built-in distro rules under /lib/udev/rules.d

Rules must end with extension ".rules" to work (unfortunately discovered the hard way).

To monitor what goes on with udev, it's practical to use:
# udevadm monitor --environment

To dump all information/properties udev knows about a device (and later use this info for writing udev rules), use:
# udevadm info -q all -n /dev/sda
or to just list all it's properties:
# udevadm info -q property -n /dev/sda

Example rules for achieving USB device affinity (that is, a USB device inserted in the same USB port should always be named the same device name):
/etc/udev/rules.d/99-usb-kalle.rules
ACTION=="add",ENV{DEVTYPE}=="disk",ENV{ID_PATH}=="pci-0000:30:00.0-usb-0:1:1.0-scsi-0:0:0:0",SYMLINK+="dock_A"
ACTION=="add",ENV{DEVTYPE}=="disk",ENV{ID_PATH}=="pci-0000:30:00.0-usb-0:2:1.0-scsi-0:0:0:0",SYMLINK+="dock_B"


Comments