Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from

Conversation

pvalena
Copy link
Contributor

@pvalena pvalena commented Jul 23, 2023

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: #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

  • I have tested it locally
  • I have reviewed and updated any documentation if relevant
  • I am providing new code and test(s) for it

@LaszloGombos
Copy link
Collaborator

LaszloGombos commented Jul 23, 2023

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) ?

@LaszloGombos LaszloGombos added the enhancement Issue adding new functionality label Jul 24, 2023
@dtardon
Copy link
Contributor

dtardon commented Jul 24, 2023

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
Copy link
Contributor Author

pvalena commented Jul 24, 2023

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


# systemd-hwdb ships the file in /etc, with /usr/lib as an alternative.
# Therefore consider this location as preferred for configuration.
hwdb_bin="${udevdir}"/hwdb.bin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${udevdir}/hwdb.bin is already unconditionally installed by 01systemd-udevd, so it can be ignored here.

Copy link
Contributor Author

@pvalena pvalena Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I was rather thinking on systemd-udevd depending on this module, which might handle hwdb in more complex way; also not install multiple ones unnecessarily. Please also note that the install is not optional (-o) intentionally; and this module is not enabled by default. Does that make sense?

There's also an additional benefit of this module working correctly without systemd-udevd :) in case that's ever needed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also an additional benefit of this module working correctly without systemd-udevd :) in case that's ever needed.

This makes sense to me. This situation is very similar to udev rules - they are installed both by systemd-udevd and udev-rules .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also an additional benefit of this module working correctly without systemd-udevd :)

That's a benefit without any value. ATM, HWDB is configuration for systemd-udevd, just like .rules files. It could be used for other things, but it's not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also an additional benefit of this module working correctly without systemd-udevd :) in case that's ever needed.

This makes sense to me. This situation is very similar to udev rules - they are installed both by systemd-udevd and udev-rules .

Uff. Does udev-rules even work on modern systems? The list of .rules files seem to be rather short. (OTOH, it contains stuff that makes no sense in initrd, like 70-uaccess.rules or 71-seat.rules.)

Copy link
Collaborator

@LaszloGombos LaszloGombos Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uff. Does udev-rules even work on modern systems?

We have a Gentoo container (with openrc and musl) where most Dracut tests pass - https://github.com/dracutdevs/dracut/blob/master/test/container/Dockerfile-Gentoo .

If Fedora wishes, it simply can just not package Dracut modules that is not needed for a systemd based initramfs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(OTOH, it contains stuff that makes no sense in initrd, like 70-uaccess.rules or 71-seat.rules.)

FWIW - both udev-rules and systemd Drauct modules seem to include these rules.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say if it's not breaking anything, let's keep it (and this also verifies hwdb.bin is present / installed, as udevd module simply runs opt-install).

@pvalena pvalena marked this pull request as ready for review July 24, 2023 08:07
@pvalena
Copy link
Contributor Author

pvalena commented Jul 25, 2023

+    # 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.

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: dracutdevs#1681
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issue adding new functionality modules Issue tracker for all modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants