11

Is it just for convenience or is there some reason for it?
Example:

cat /etc/udev/conf.d/rules.d/98-kexec.rules
PersianGulf
  • 10,850
D.Zou
  • 405

1 Answers1

7

You could read why directly from the manual.

man udev

RULES FILES

The udev rules are read from the files located in the system rules directory /usr/lib/udev/rules.d, the volatile runtime directory /run/udev/rules.d and the local administration directory /etc/udev/rules.d. All rules files are collectively sorted and processed in lexical order, regardless of the directories in which they live. However, files with identical file names replace each other. Files in /etc have the highest priority, files in /run take precedence over files with the same name in /lib. This can be used to override a system-supplied rules file with a local file if needed; a symlink in /etc with the same name as a rules file in /lib, pointing to /dev/null, disables the rules file entirely.

user.dz
  • 1,875
  • 1
    If you want to create a custom udev rule, are there some guidelines for choosing the number prefix? – jarno Nov 02 '21 at 17:08
  • 2
    Oh, there are some guidelines. – jarno Nov 02 '21 at 17:27
  • @jarno Good you find one. They are ordered and they may depend on each other. Best to put it just higher then the rules file you want to customize or make addition to. and same number & same name if you want full override. Also if your rules are just action that don't affect driver and system decision, put them in the end as every node meta will be stable at that level. – user.dz Nov 02 '21 at 17:34
  • Yes, I just found out that my custom USB wakeup rule had an effect only, if the number is 50 or higher; I suppose it is due to /usr/lib/udev/rules.d/50-udev-default.rules – jarno Nov 02 '21 at 17:51
  • 1
    @jarno You may use udevadm test ... to verify which rules are loaded for that device and action applied on it. – user.dz Nov 02 '21 at 18:20