dracutdevs / dracut

dracut the event driven initramfs infrastructure
https://github.com/dracutdevs/dracut/wiki
GNU General Public License v2.0
604 stars 400 forks source link

feat(hwdb): install hwdb on demand when module is needed #2443

Closed pvalena closed 6 months ago

pvalena commented 1 year ago

Changes

Adding a module to install hwdb. Further extensions might make only selected part of hwdb installable, to save space. The module is not included by default.

Including the module adds 2MB of compressed data (on Fedora, the file has 12MB).

hwdb is needed in case of custom HW, like a keyboard/mouse or various interfaces.

Original PR: https://github.com/dracutdevs/dracut/pull/1681 Downstream Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1968118

Please note that hwdb.bin is similarly installed by systemd-udevd, which could instead pull in this module as dependency.

Checklist

LaszloGombos commented 1 year ago

I like and support this approach.

Note that the downstream issue would not be resolved unless somehow hwdb.d/20-net-ifname.hwdb also gets installed into the initramfs.

Is that outside of the scope of this PR (perhaps it should be) ?

dtardon commented 1 year ago

Note that the downstream issue would not be resolved unless somehow hwdb.d/20-net-ifname.hwdb also gets installed into the initramfs.

No, that's not needed. .hwdb files are not used directly; they must first be compiled into hwdb.bin, which is a binary format optimized for fast lookup. The compilation (udevadm hwdb --update) is out of scope of udevd. E.g., in rpm world it is likely done in %post (or %posttrans) of any package that installs a .hwdb file. Hence, dracut only needs to install hwdb.bin file(s).

pvalena commented 1 year ago

Note that the downstream issue would not be resolved unless somehow hwdb.d/20-net-ifname.hwdb also gets installed into the initramfs.

No, that's not needed. .hwdb files are not used directly; they must first be compiled into hwdb.bin, which is a binary format optimized for fast lookup. The compilation (udevadm hwdb --update) is out of scope of udevd. E.g., in rpm world it is likely done in %post (or %posttrans) of any package that installs a .hwdb file. Hence, dracut only needs to install hwdb.bin file(s).

Exactly. I've just confirmed: https://gist.github.com/pvalena/873bed9e9eb749f127ca7f60c330dd3d

pvalena commented 1 year ago
+    # The alternative location is preferred, as we can consider it being user
+    # configuration.

IOW first looks in /usr and then in /etc. I don't know what systemd-hwdb behaviour is, it might be best to mimic it. Either way I see having hwdb.bin in both locations (or installing it) undesirable.