]> git.ipfire.org Git - thirdparty/dracut-ng.git/commit
feat(dracut): introduce additional hooks locations
authorVitaly Kuznetsov <vkuznets@redhat.com>
Mon, 6 Oct 2025 14:54:46 +0000 (16:54 +0200)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Wed, 4 Feb 2026 16:55:21 +0000 (11:55 -0500)
commit04d5e2944e1b1a85a945910995cb8df00d983a7c
tree5f52216e71195c921a5e80e85b292c540aa3f029
parentd900521b7b8ebe8a5eb200807aca258075725e4a
feat(dracut): introduce additional hooks locations

Dracut init supports running custom hooks which are placed to
/var/lib/dracut/hooks/. The location was previously changed to /var
as the place needs to be writeable as some hooks are created and removed
in runtime. The current location, however, may come inconvenient in some
scenarios when the user wants to extend initramfs with custom scripts. In
particular, systemd allows extending initrd with 'sysext' and 'confext'
mechanism. This comes handy for extending e.g. UKI's initramfs without
the need to rebuild (and re-sign) the UKI. The problem is that 'sysext' can
only be used to extend /usr and /opt and 'confext/ can only extend /etc.
Both services make the location read-only and thus can't be used for the
main dracut hooks location even if we move it somewhere.

Add additional locations where users can put dracut hooks:
- /lib/dracut/hooks -- this location is supposed to be used for
  distro-specific static hooks.
- /etc/dracut/hooks -- this location can be used by users for locally
  created hooks.
- /var/lib/dracut/hooks -- the default location which is supposed to be
  used by dracut modules. This location is always writeable so modules
  can place and remove hooks from there in runtime. The existing '$hookdir'
  variable keeps pointing at this place.

Dracut also has support for /var/lib/dracut/hooks/initqueue/work flag and
in theory, it does not have to be in the hooks directory as it is not a
hook. The location, however, is documented and it is not entirely clear
if it would make sense to add support for /lib/dracut/hooks/initqueue/work
and /etc/dracut/hooks/initqueue/work as well: these locations can (and
probably should) be read-only so creating/removing flag there is hard. Keep
the status quo and only support '$hookdir/initqueue/work' for now.

Closes: https://github.com/dracut-ng/dracut-ng/issues/1618
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
12 files changed:
doc_site/modules/ROOT/pages/developer/modules.adoc
dracut.sh
man/dracut.modules.7.adoc
modules.d/77dracut-systemd/dracut-cmdline.service
modules.d/77dracut-systemd/dracut-mount.service
modules.d/77dracut-systemd/dracut-pre-mount.service
modules.d/77dracut-systemd/dracut-pre-pivot.service
modules.d/77dracut-systemd/dracut-pre-trigger.service
modules.d/77dracut-systemd/dracut-pre-udev.service
modules.d/80base/dracut-lib.sh
modules.d/80base/module-setup.sh
modules.d/86shutdown/module-setup.sh