It appears that the ENV
variables are pretty free-form and bound to devices. The only enforced restrictions is that none of these keys may be be used: ACTION, SUBSYSTEM, DEVTYPE, MAJOR, MINOR, DRIVER, IFINDEX, DEVNAME, DEVLINKS, DEVPATH, TAGS.
Other than that, interpretation of the environment variables is left to other rules and programs. Use grep -rni 'ENV{' /{lib,etc}/udev/rules.d
to find the consumers and providers of environment variables. In your specific REMOVE_CMD
case, the file /lib/udev/rules.d/50-udev-default.rules
is responsible for handling this action:
# run a command on remove events
ACTION=="remove", ENV{REMOVE_CMD}!="", RUN+="$env{REMOVE_CMD}"
ACTION=="remove", GOTO="default_end"
With this command you can find more environment variables:
grep -hrPo 'ENV{\K[^}]*(?=}=[^=])' /{etc,lib}/udev/rules.d | sort -u
As an example, consider the 95-upower-hid.rules
file. This file sets the UPOWER_BATTERY_TYPE
variable. No other rules use this file, but the UPower daemon registers to udevd for add/change/remove events. Then when an event occurs, UPower specifically queries the device for this variable in order to determine whether it should treat is as regular mice, UPSes or Unifying receiver devices.
Another (more useful) example is the UDISKS_IGNORE
environment variable which can be used to hint graphical file browsers to hide the device in the drives list. Specifically for udisks2, you can find the variables in udisks(8) manual page (located this using man -K UDISKS_IGNORE
).