Alongside an RPM package, I have been preparing a DEB package for some software which requires the installation of some udev rules.
My RPM package installs the rules in
/usr/lib/udev/rules.d. My understanding is that
/usr/lib/udev/rules.d is where the rules of third-party (non-distro) packages are supposed to reside.
I've tested the RPM package on Fedora 35 - all good. The rules are applied when the relevant udev events are triggered.
My DEB package currently installs the same rules in the same place, but when testing the DEB package on a fresh install of Ubuntu 18.04, the installed rules are not being applied (when I trigger the relevant udev events). I was able to get it working by moving the rules to
/etc/udev/rules.d. This makes me suspect that rules in
/usr/lib/udev/rules.d are not loaded, on Debian-based systems.
After a little research, all of the documentation I've found (RE udev rules on Debian) claims that Debian expects the rule files to be placed in
The rules files (which amount to more configuration for udevd) are taken from /run/udev/rules.d, /etc/udev/rules.d or /lib/udev/rules.d. Packages install rules in /lib/udev/rules.d), while the /etc and /run locations provide a facility for the administrator to override the behavior of a package-provided rule.
I was under the impression that the
/lib directory was for packages that are considered to be essential to the system. From the FHS:
The /lib directory contains those shared library images needed to boot the system and run the commands in the root filesystem, ie. by binaries in /bin and /sbin.
Where am I to put these udev rules? My package is certainly not considered to be essential to the system. If I put them in
/lib, isn't that going against the FHS? And finally, should the location really differ across distros? Why can't I just put them in one place, across all Linux distros?
I've just realised that, since Ubuntu 20.04,
/lib is symlinked to
/usr/lib, so the location of the udev rules will probably be less of a problem on those systems, but I'd still like to know where I should put them, on Ubuntu 18.04 systems.