meta data for this page
This is an old revision of the document!
udevadm
reloading rules
udevadm control --reload-rules
Testing rules
udevadm test /sys/class/tty/ttyACM0
Getting info
udevadm info –attribute-walk –path=/sys/class/tty/ttyACM0
Get Telit modem serial number
udevadm info -q property -n /dev/ttyACM1 | grep ID_SERIAL_SHORT ID_SERIAL_SHORT=356136070718830
Debug
- /etc/udev/udev.conf
udev_log="debug"
Rules
Order
Files should be named xx-descriptive-name.rules, the xx should be chosen first according to the following sequence points:
< 60 most user rules; if you want to prevent an assignment being overriden by default rules, use the := operator.
these cannot access persistent information such as that from vol_id
< 70 rules that run helpers such as vol_id to populate the udev db
< 90 rules that run other programs (often using information in the udev db)
>=90 rules that should run last
Executing commands
Triggering commands should be done using RUN, because it is executed after all systemd actions.
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="/usr/bin/true" SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", RUN+="/usr/bin/true"
RUN vs PROGRAM
PROGRAM is used to return device name, e.g. to return name for symlink. It is called during device setup, so it is not good place to execute external tools.
Creating device symlinks
SUBSYSTEM=="input", KERNEL=="event[0-9]*", ENV{ID_INPUT_TOUCHSCREEN}=="1", ATTRS{name}=="edt-ft53*", SYMLINK+="input/touchscreen", OPTIONS+="link_priority=100" SUBSYSTEM=="input", KERNEL=="event[0-9]*", ENV{ID_INPUT_TOUCHSCREEN}=="1", ATTRS{name}=="ti-tsc", SYMLINK+="input/touchscreen", OPTIONS+="link_priority=0"
link_priority
: higher has higher priority
Triggering systemd
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", TAG+="systemd", ENV{SYSTEMD_WANTS}="powersaving.service" SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", TAG+="systemd", ENV{SYSTEMD_WANTS}="powersaving.service" SUBSYSTEM=="printer", TAG+="systemd", ENV{SYSTEMD_WANTS}="printer.target"