Skip to content

Maintaining systemd udev HWDB for NUT

Jim Klimov edited this page Jul 4, 2023 · 2 revisions

Some system-local setups go into greater detail than NUT generated udev.rules files go, e.g. to create a named definitively named symbolic link for their UPS regardless of the USB port/device enumeration:

ATTRS{idVendor}=="1234", ATTRS{idProduct}=="5678", ATTRS{serial}=="SN123456", SYMLINK+="ttyUSB-nut", GROUP="nut", MODE="0664"

NOTE: Currently most of the NUT USB drivers rely on libusb for device enumeration and so ignore the path provided in the generally required port configuration parameter (hence port=auto). However for UPSes which include a serial-over-USB chip, or for serial-port UPSes connected to a USB port of the computer using a separate dongle, the path to the serial port device node does matter (hence the usefulness of symlinks).

The rule set above also matches an USB device serial number -- combined with SYMLINK this can help definitively name several unique USB UPS devices monitored by the same system. Note however that not all vendors provide the value, or a unique one - e.g. all-zeroes or all-spaces does happen.

See also https://www.freedesktop.org/software/systemd/man/hwdb.html

See also http://who-t.blogspot.com/2019/02/adding-entries-to-udev-hwdb.html about more details on editing HWDB in a live system, and possibly more tricks to apply it.

Clone this wiki locally