]> git.ipfire.org Git - thirdparty/dracut-ng.git/log
thirdparty/dracut-ng.git
5 months agofix(dracut.sh): do not use uname to detect kernel version in a container
Jo Zzsi [Wed, 16 Jul 2025 14:21:01 +0000 (10:21 -0400)] 
fix(dracut.sh): do not use uname to detect kernel version in a container

A big general papercut with dracut right now in that it always assumes
the kernel it's running on is the kernel to target.

This commit lets dracut to detect that it's in a container (e.g. systemd-detect-virt -c),
and check for a single /usr/lib/modules/$kver directory and automatically use that kernel.

Currently this kernel version detection has three copies in the source
(dracut.sh, lsinitrd.sh,test-functions). This commit keeps the
logic for the three copies the same. As a follow-up commit, we should
try to actually share the code for this logic instead of copying it.

Fixes https://github.com/dracut-ng/dracut-ng/issues/1455.

5 months agofix(dmsquash-live): erofs collision with latest util-linux
Karel Zak [Thu, 19 Jun 2025 16:32:13 +0000 (12:32 -0400)] 
fix(dmsquash-live): erofs collision with latest util-linux

This PR fixes the issue that recent kernels can mount EROFS
directly without loop devices, and this feature is enabled in Fedora
kernels (>=6.12; CONFIG_EROFS_FS_BACKED_BY_FILE=y).
This feature is now supported by mount/libmount, too.

I think the best approach would be to avoid the second mount altogether,
independently of the util-linux version.
It is more robust to use a bind mount there than to attempt to create
a second instance of the same file system.

Fixes: https://github.com/dracut-ng/dracut-ng/issues/1384
5 months agochore: eliminate overlapping functions
Jo Zzsi [Tue, 15 Jul 2025 02:06:42 +0000 (22:06 -0400)] 
chore: eliminate overlapping functions

In its current form inst_library function executes the same set of
commands as the inst function.

Copying (instead of reusing code) is usually preferred, especially
in this particular case where inst_library function is not used by
dracut, so it is not tested by dracut CI.

After this commit, inst_library would just call inst, and inst
is being used and as such tested by dracut CI, so it makes it
less likely to egress out-of tree coide depending on dracut.

5 months agofix(dracut): ensure hardlink deduplication is reproducible
Chris Riches [Wed, 9 Jul 2025 16:40:18 +0000 (16:40 +0000)] 
fix(dracut): ensure hardlink deduplication is reproducible

By default, hardlink will only deduplicate files with identical mtimes,
down to one-second granularity. If a dracut module rapidly generates
multiple identical files, it is completely up to chance as to whether
their mtimes cross a second boundary or not, and thus whether they get
deduplicated or not. This results in non-reproducible output.

Re-order hardlink with respect to clamping to avoid this problem.

Fixes: https://issues.redhat.com/browse/RHEL-101901
5 months agotest(SYSTEMD): convert test to run without initqueue
Jo Zzsi [Tue, 15 Jul 2025 02:55:31 +0000 (22:55 -0400)] 
test(SYSTEMD): convert test to run without initqueue

Systemd itself provides similar functionality to the
dracut initqueue module. It has been a long-standing
criticism of dracut systemd integration that
initqueue should not be necessary for most system boot scenarios.

While there is still a long way to go, we can start testing some of
the common systemd boot scenarios without initqueue.

See https://github.com/dracut-ng/dracut-ng/issues/1191

5 months agotest: remove hard-off test hooks hooks
Jo Zzsi [Thu, 3 Jul 2025 16:15:21 +0000 (12:15 -0400)] 
test: remove hard-off test hooks hooks

These hard-off test hooks make the test shut down in a
non-graceful way.

These hooks are no longer required.

Removing these hooks would make the test run similarly
to production environments.

5 months agofix: network-manager dracut module no longer depends on systemd
Jo Zzsi [Sun, 13 Jul 2025 22:26:03 +0000 (18:26 -0400)] 
fix: network-manager dracut module no longer depends on systemd

Previously dracut network-manager module only worked with systemd.

Now after 58baf86, network-manager dracut module should work
in non-systemd Linux distributions as well, such as Void Linux.

This commit re-enables network-manager dracut module for all
Linux distributions.

5 months agofix(dracut.conf.d): reserve namespace 50 to out-of-tree configurations
Jo Zzsi [Sat, 12 Jul 2025 17:08:20 +0000 (13:08 -0400)] 
fix(dracut.conf.d): reserve namespace 50 to out-of-tree configurations

50 should be reserved for out-of-tree dracut configurations, just like
50 is reserved for out-of-tree dracut modules. This policy makes dracut
more consistent and easier to reason about.

Change the built-in dracut configurations from namespace 50 to namespace 10.

Document that the recommended ordering for distribution or user provided
configuration files is in the range of 50-59.

5 months agoci(gentoo): remove workaround for forcing hostonly mode
Jo Zzsi [Sat, 12 Jul 2025 16:58:08 +0000 (12:58 -0400)] 
ci(gentoo): remove workaround for forcing hostonly mode

Forcing hostonly mode for Gentoo was introduced in commit
9fc9128, as a step towards enabling hostonly mode by default
for all distributions.

After 62fdf59 this workaround for Gentoo is no longer needed to
be maintained as now hostonly is the default for all Linux
installation (set in configure).

5 months agoci: install NetworkManager into the Void CI container
Jo Zzsi [Sun, 13 Jul 2025 22:36:56 +0000 (18:36 -0400)] 
ci: install NetworkManager into the Void CI container

Previously dracut network-manager package only worked with systemd.
Now after 58baf86, network-manager dracut package should work in
non-systemd Linux distributions as well, such as Void Linux.

Install NetworkManager into the Void CI container to enable
testing it on the CI.

5 months agofix(fips): make sha512hmac an optional requirement
Jo Zzsi [Sat, 12 Jul 2025 16:34:33 +0000 (12:34 -0400)] 
fix(fips): make sha512hmac an optional requirement

sha512hmac binary is not available on most Linux distributions,
including openSUSE and it is not a hard requirement for the
fips dracut module to function.

Install sha512hmac with an optional flag to not regress
distributions that have sha512hmac installed and also
enable distributions without sha512hmac to not fail.

5 months agofeat(rootfs-block-fallback): factor out rootfallback into its own module
Jo Zzsi [Sat, 24 May 2025 10:59:39 +0000 (06:59 -0400)] 
feat(rootfs-block-fallback): factor out rootfallback into its own module

This change allows to remove the initqueue dependency from
rootfs-block.

initqueue will be only included into the initramfs when
rootfs-block-fallback is explicitelly included.

5 months agofix(base): dracut-lib.sh soft depends on poweroff/reboot/halt
Jo Zzsi [Thu, 3 Jul 2025 17:37:35 +0000 (13:37 -0400)] 
fix(base): dracut-lib.sh soft depends on poweroff/reboot/halt

Currently base module does not include poweroff/reboot/halt
even though dracut-lib.sh could call these binaries. Dracut
should make it easier to create an initramfs that has all
the dependent libraries.

After this change we can remove poweroff - which was a workaround
for the base module bug - from test modules.

5 months agofix(man): document what to expect running dracut non-root
Jo Zzsi [Sat, 12 Jul 2025 23:04:05 +0000 (19:04 -0400)] 
fix(man): document what to expect running dracut non-root

Running dracut non-root supports only a limited set of functionalities.

5 months agofix(systemd-sysusers): remove (g)shadow created by systemd-sysusers
Jo Zzsi [Wed, 21 May 2025 12:38:30 +0000 (08:38 -0400)] 
fix(systemd-sysusers): remove (g)shadow created by systemd-sysusers

The files shadow and gshadow do NOT exist when using the commit before f3dacc0.

This commit restores the earlier behaviour.

Fixes #1242

5 months agofix(systemd-repart): allow partition format
Emanuele Giuseppe Esposito [Fri, 20 Jun 2025 12:38:27 +0000 (08:38 -0400)] 
fix(systemd-repart): allow partition format

systemd-repart is capable not only of creating a partition, but also of
formatting it. According with repart.d, it is able to create the
following filesystems: ext4, btrfs, xfs, vfat, erofs and squashfs.

Add support in the systemd-repart module for the underlying tools to
allow systemd-repart to format the partition.

Failure to do so would make systemd-repart initramfs unit fail, if
Format= option is provided in a repart.d config file.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
5 months agofix(dracut-install): sort output of --modalias
Benjamin Drung [Wed, 9 Jul 2025 10:28:51 +0000 (12:28 +0200)] 
fix(dracut-install): sort output of --modalias

Calling `dracut-install --modalias` will print kernel modules in an
unstable order. This breaks reproducible builds, because the output is
stored inside the initrd as `lib/dracut/hostonly-kernel-modules.txt`.

So sort the output of `--modalias` to be reproducible and easier to
diff.

Partially fixes https://github.com/dracut-ng/dracut-ng/issues/1409

5 months agorefactor(dracut-install): add print_values helper function
Benjamin Drung [Wed, 9 Jul 2025 10:03:37 +0000 (12:03 +0200)] 
refactor(dracut-install): add print_values helper function

5 months agorefactor(dracut): introduce clamp_mtimes helper function
Chris Riches [Thu, 3 Jul 2025 13:42:09 +0000 (13:42 +0000)] 
refactor(dracut): introduce clamp_mtimes helper function

Avoid code duplication by introducing `clamp_mtimes`.

5 months agoRevert "chore: remove unused function"
Adam Williamson [Thu, 10 Jul 2025 17:33:21 +0000 (10:33 -0700)] 
Revert "chore: remove unused function"

This reverts commit 81ddde54051351ea17dbb84ef6232820f96740af.
dracut itself may not use inst_library, but external modules do,
at least anaconda's does.

5 months agofix(lsinitrd): resolve initrd to real path
Benjamin Drung [Tue, 8 Jul 2025 15:58:18 +0000 (17:58 +0200)] 
fix(lsinitrd): resolve initrd to real path

`lsinitrd /boot/initrd.img` fails in case the initrd is zstd compressed:

```
$ dracut --zstd --no-early-microcode --force
$ 3cpio --examine /boot/initrd.img
0 zstd
$ lsinitrd /boot/initrd.img
Image: /boot/initrd.img: 0
========================================================================
Warning : /boot/initrd.img is a symbolic link, ignoring
Version:

Arguments:
dracut modules:
Warning : /boot/initrd.img is a symbolic link, ignoring
Warning : /boot/initrd.img is a symbolic link, ignoring
========================================================================
========================================================================
cpio: premature end of archive

dracut cmdline:
Warning : /boot/initrd.img is a symbolic link, ignoring
```

The `CAT` variable is `zstd -d -c`. The zstd man page says about the
`--force` parameter: "disable input and output checks. Allows [...]
operating on links". So this zstd behavior is intentional.

Resolve the initrd path to the real path. Then `lsinitrd` prints the
correct content and image size:

```
$ lsinitrd /boot/initrd.img
Image: /boot/initrd.img-6.14.0-23-generic: 15M
[...]
```

Bug-Ubuntu: https://launchpad.net/bugs/2116183

5 months agofix(network-manager): depend on dbus only when using systemd
Andrew Gunnerson [Sun, 6 Jul 2025 04:21:53 +0000 (00:21 -0400)] 
fix(network-manager): depend on dbus only when using systemd

network-manager does not require dbus to function when using the
--configure-and-quit=initrd option. This should be guaranteed as it is
documented behavior in the NetworkManager.conf(5) manpage and
specifically mentions dracut's use case.

With this change, initramfs images that don't or can't use systemd can
use network-manager instead of the old network-legacy module.

Fixes: #1422
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
5 months agorefactor(dracut-install): copy_xattr: more idiomatic loop
Marcos Mello [Tue, 8 Jul 2025 22:06:09 +0000 (19:06 -0300)] 
refactor(dracut-install): copy_xattr: more idiomatic loop

Update the loop to more idiomatic iteration over null-terminated
strings.

5 months agorefactor(dracut-install): copy_xattr: use malloc rather than calloc
Marcos Mello [Tue, 8 Jul 2025 22:03:39 +0000 (19:03 -0300)] 
refactor(dracut-install): copy_xattr: use malloc rather than calloc

Replace calloc() with malloc() as flistxattr() overwrites the buffer
and ensures null-terminated xattr names.

5 months agorefactor(dracut-install): copy_xattr: use _cleanup_free_
Marcos Mello [Tue, 8 Jul 2025 22:01:42 +0000 (19:01 -0300)] 
refactor(dracut-install): copy_xattr: use _cleanup_free_

Use _cleanup_free_ for buffers and remove unnecessary variable
initializations.

5 months agorefactor(dracut-install): copy_xattr: return early when no xattrs are present
Marcos Mello [Tue, 8 Jul 2025 21:57:32 +0000 (18:57 -0300)] 
refactor(dracut-install): copy_xattr: return early when no xattrs are present

5 months agofix(systemd-sysext): install the required kernel modules
Vitaly Kuznetsov [Mon, 23 Jun 2025 13:29:12 +0000 (15:29 +0200)] 
fix(systemd-sysext): install the required kernel modules

'systemd-repart' tool is commonly used to produce Discoverable Disk Image
(DDI) ("--make-ddi=TYPE" option) and by default the tool creates 'erofs'
root volume for sysext/confext. Include 'erofs' kernel module into
initramfs if present.

While on in, include 'loop' module as well as this one is an absolute must.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
5 months agofix: support DRACUT_SYSTEMD being unset
Benjamin Drung [Fri, 20 Jun 2025 20:10:54 +0000 (22:10 +0200)] 
fix: support DRACUT_SYSTEMD being unset

Support `DRACUT_SYSTEMD` being unset when using `set -u`.

5 months agofeat: add support for removing a space separated list of files
Jo Zzsi [Sun, 27 Apr 2025 20:01:27 +0000 (16:01 -0400)] 
feat: add support for removing a space separated list of files

Fixes: https://github.com/dracut-ng/dracut-ng/issues/1297
5 months agorevert: bump tomtom-international/commisery-action from 3 to 4
Jo Zzsi [Tue, 1 Jul 2025 23:25:34 +0000 (19:25 -0400)] 
revert: bump tomtom-international/commisery-action from 3 to 4

Why: v4 fails for this project, v3 does not fail.

5 months agotest(GETARGS): set NEWROOT and PREFIX for dracut-lib.sh
Benjamin Drung [Fri, 27 Jun 2025 13:47:52 +0000 (15:47 +0200)] 
test(GETARGS): set NEWROOT and PREFIX for dracut-lib.sh

Set `NEWROOT` to an existing directory to make sourcing `dracut-lib.sh`
work with `set -u`. Also set `PREFIX` to avoid creating `/run/initramfs`
which requires root permission.

5 months agofeat: make variable set check work with "set -u"
Benjamin Drung [Fri, 20 Jun 2025 20:55:18 +0000 (22:55 +0200)] 
feat: make variable set check work with "set -u"

Make checking if a variable is defined/set work with `set -u`.

5 months agofix(base): support PREFIX being unset
Benjamin Drung [Fri, 20 Jun 2025 17:57:40 +0000 (19:57 +0200)] 
fix(base): support PREFIX being unset

Support `PREFIX` being unset when using `set -u`.

5 months agotest: change tests to recommended configuration
Jo Zzsi [Sat, 28 Jun 2025 15:09:48 +0000 (11:09 -0400)] 
test: change tests to recommended configuration

Follow-up to f698315 .

In most cases the "--add-drivers" option is what you want to use.

5 months agofix: support hostonly being unset
Benjamin Drung [Fri, 20 Jun 2025 17:56:27 +0000 (19:56 +0200)] 
fix: support hostonly being unset

Support `hostonly` being unset when using `set -u`.

5 months agochore(deps): bump tomtom-international/commisery-action from 3 to 4
dependabot[bot] [Tue, 1 Jul 2025 20:54:50 +0000 (20:54 +0000)] 
chore(deps): bump tomtom-international/commisery-action from 3 to 4

Bumps [tomtom-international/commisery-action](https://github.com/tomtom-international/commisery-action) from 3 to 4.
- [Release notes](https://github.com/tomtom-international/commisery-action/releases)
- [Commits](https://github.com/tomtom-international/commisery-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: tomtom-international/commisery-action
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
5 months agofix(modules): free up range 00-09 to out of tree dracut modules
Jo Zzsi [Mon, 26 May 2025 15:43:46 +0000 (11:43 -0400)] 
fix(modules): free up range 00-09 to out of tree dracut modules

This PR does not change the ascending sort order of the modules.

It adds 10 to all dracut modules in the range of 00-10 to move it up
to the 10-20 range.

The motivation for this PR is to have namespace (dracut module numbers)
reserved at the beginning (similar to the end) of the range.

Fixes https://github.com/dracut-ng/dracut-ng/issues/538.

6 months agoperf(watchdog): only install wdctl for the non-systemd case
Jo Zzsi [Thu, 29 May 2025 14:06:26 +0000 (10:06 -0400)] 
perf(watchdog): only install wdctl for the non-systemd case

Move the installation of wdctl in install() to the non-systemd block as
systemd doesn't use it, so it's only needed by watchdog.sh.

6 months agofeat(watchdog): do not depend on initqueue if systemd is used
Jo Zzsi [Thu, 29 May 2025 14:04:34 +0000 (10:04 -0400)] 
feat(watchdog): do not depend on initqueue if systemd is used

initqueue is not used when systemd is included in the initramfs.

6 months agofeat(resume): do not depend on initqueue if systemd is used
Jo Zzsi [Tue, 27 May 2025 11:57:11 +0000 (07:57 -0400)] 
feat(resume): do not depend on initqueue if systemd is used

initqueue is not used when systemd is included in the initramfs.

Fixes https://github.com/dracut-ng/dracut-ng/issues/1362 .

6 months agotest: add --pbkdf pbkdf2 to luksFormat commands
Jo Zzsi [Sat, 28 Jun 2025 16:33:16 +0000 (12:33 -0400)] 
test: add --pbkdf pbkdf2 to luksFormat commands

Make the test work with recent release (v2.8.0) of cryptsetup.

This PR keeps memory requirements for LUKS unlocking minimal,
allowing testcases run in system with minimal memory.

The storage stack and boot process that is being tested,
remains exactly the same.

Default for LUKS2 is now Argon2 (memory-hard KDF,
so it means that it requires some amount of memory).

Fixes: https://github.com/dracut-ng/dracut-ng/issues/1389
6 months agodocs: improve documentation for out of tree dracut modules
Jo Zzsi [Sat, 28 Jun 2025 13:48:33 +0000 (09:48 -0400)] 
docs: improve documentation for out of tree dracut modules

Follow-up to 2199846.

Partially resolve #538.

6 months agochore: version lock commisery-action
Jo Zzsi [Thu, 19 Jun 2025 16:05:06 +0000 (12:05 -0400)] 
chore: version lock commisery-action

@master seems to report the folloeing error

Error: Resource not accessible by integration

Switch to @v3, as it is the last stable version.

6 months agofeat(network-manager): use upstream initrd services if available
Antonio Alvarez Feijoo [Fri, 13 Jun 2025 07:30:11 +0000 (09:30 +0200)] 
feat(network-manager): use upstream initrd services if available

Added in https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/commit/8640ea822f054c8817e0fd773ba7d1a8f42fa214

6 months agofeat: support dracutsysrootdir being unset
Benjamin Drung [Wed, 11 Jun 2025 15:21:14 +0000 (17:21 +0200)] 
feat: support dracutsysrootdir being unset

Support `dracutsysrootdir` being unset when using `set -u`.

6 months agotest: support DEBUGFAIL being unset
Benjamin Drung [Fri, 13 Jun 2025 10:22:04 +0000 (12:22 +0200)] 
test: support DEBUGFAIL being unset

Support `DEBUGFAIL` being unset when using `set -u`.

6 months agotest: support V being unset
Benjamin Drung [Wed, 11 Jun 2025 18:53:09 +0000 (20:53 +0200)] 
test: support V being unset

Support `V` being unset when using `set -u`.

6 months agotest: support CPIO_TESTDIR being unset in test_cleanup
Benjamin Drung [Wed, 11 Jun 2025 18:37:35 +0000 (20:37 +0200)] 
test: support CPIO_TESTDIR being unset in test_cleanup

Support `CPIO_TESTDIR` being unset when using `set -u`.

6 months agotest: support DEBUGOUT being unset
Benjamin Drung [Wed, 11 Jun 2025 18:36:04 +0000 (20:36 +0200)] 
test: support DEBUGOUT being unset

Support `DEBUGOUT` being unset when using `set -u`.

6 months agotest: support SERVER_DEBUG being unset
Benjamin Drung [Wed, 11 Jun 2025 18:21:52 +0000 (20:21 +0200)] 
test: support SERVER_DEBUG being unset

Support `SERVER_DEBUG` being unset when using `set -u`.

6 months agotest: support SERIAL being unset
Benjamin Drung [Wed, 11 Jun 2025 18:19:16 +0000 (20:19 +0200)] 
test: support SERIAL being unset

Support `SERIAL` being unset when using `set -u`.

6 months agofix(dracut-logger.sh): initialize errmsg in dlog_init
Benjamin Drung [Fri, 13 Jun 2025 10:17:53 +0000 (12:17 +0200)] 
fix(dracut-logger.sh): initialize errmsg in dlog_init

Initialize the local variable `errmsg` in `dlog_init` to make the
function work with `set -u`.

6 months agotest: initialize bootindex in qemu_add_drive
Benjamin Drung [Fri, 13 Jun 2025 10:28:22 +0000 (12:28 +0200)] 
test: initialize bootindex in qemu_add_drive

Initialize the optional variables in `bootindex` to make the function
work with `set -u`.

6 months agofix: support DRACUT_RESOLVE_LAZY being unset
Benjamin Drung [Wed, 11 Jun 2025 18:46:22 +0000 (20:46 +0200)] 
fix: support DRACUT_RESOLVE_LAZY being unset

Support `DRACUT_RESOLVE_LAZY` being unset when using `set -u`.

6 months agofix(dracut-init.sh): support DRACUT_NO_XATTR being unset
Benjamin Drung [Wed, 11 Jun 2025 18:44:25 +0000 (20:44 +0200)] 
fix(dracut-init.sh): support DRACUT_NO_XATTR being unset

Support `DRACUT_NO_XATTR` being unset when using `set -u`.

6 months agofix(Makefile): remove test modules after renumbering
Benjamin Drung [Wed, 11 Jun 2025 12:34:18 +0000 (14:34 +0200)] 
fix(Makefile): remove test modules after renumbering

The test modules were renumbered from 80 to 70, but the Makefile did not
adjust to this change.

Fixes: 2199846ffebc ("fix(modules): all modules with 99 ordering should have a unique number")
6 months agofix(test): renumber test modules to 70
Benjamin Drung [Wed, 11 Jun 2025 12:32:15 +0000 (14:32 +0200)] 
fix(test): renumber test modules to 70

Renumber the test modules from 80 to 70 (not just rename the symlinks).

Fixes: 2199846ffebc ("fix(modules): all modules with 99 ordering should have a unique number")
6 months agofix(dracut-init.sh): initialize _files in inst_libdir_file
Benjamin Drung [Wed, 11 Jun 2025 17:59:59 +0000 (19:59 +0200)] 
fix(dracut-init.sh): initialize _files in inst_libdir_file

Initialize the local variable `_files` in `inst_libdir_file` to make the
function work with `set -u`.

6 months agofix(dracut-lib.sh): initialize variables in getargs
Benjamin Drung [Wed, 11 Jun 2025 17:56:56 +0000 (19:56 +0200)] 
fix(dracut-lib.sh): initialize variables in getargs

Initialize the variables in `getargs` to make the function work with
`set -u`.

6 months agofix(dracut.sh): initialize variables that get exported
Benjamin Drung [Wed, 11 Jun 2025 18:15:37 +0000 (20:15 +0200)] 
fix(dracut.sh): initialize variables that get exported

`dracut.sh` exports several variables. Initialize them empty instead of
leaving them potentially undefined.

6 months agofix: loongarch architecture support
zhuyaliang [Wed, 11 Jun 2025 01:34:08 +0000 (09:34 +0800)] 
fix: loongarch architecture support

6 months agofeat(base): add support for rd.driver.pre
Jo Zzsi [Mon, 26 May 2025 00:44:07 +0000 (20:44 -0400)] 
feat(base): add support for rd.driver.pre

Move support for rd.driver.pre from kernel-modules to base
module.

One of the reason for this is as rd.driver.pre has a dependency on
modprobe binary and modprobe binary is installed in the base
dracut module.

Another reason is to support the use case where kernel modules
are installed via dracut command line and not via kernel-modules
dracut library.

Fixes https://github.com/dracut-ng/dracut-ng/issues/1302

6 months agofeat: tests are not packaged by default to simplify packaging
Jo Zzsi [Sun, 18 May 2025 17:17:31 +0000 (13:17 -0400)] 
feat: tests are not packaged by default to simplify packaging

If it is desired to package tests, set enable_test=yes .

Fixes: https://github.com/dracut-ng/dracut-ng/issues/1327
7 months agofix(base): only create nobody user for nfs dracut module
Jo Zzsi [Sun, 9 Feb 2025 15:33:34 +0000 (10:33 -0500)] 
fix(base): only create nobody user for nfs dracut module

Usual local initrd does not need nobody user.

7 months agofix(systemd-sysext): make non-hostonly non-host
Jo Zzsi [Fri, 25 Apr 2025 16:49:22 +0000 (12:49 -0400)] 
fix(systemd-sysext): make non-hostonly non-host

/var is by definition host specific.

7 months agofix(systemd): systemd.volatile needs overlayfs kernel module
Jo Zzsi [Sun, 25 May 2025 20:16:40 +0000 (16:16 -0400)] 
fix(systemd): systemd.volatile needs overlayfs kernel module

See https://www.freedesktop.org/software/systemd/man/latest/systemd-volatile-root.service.html

> This service is only enabled if full volatile mode is selected,
> for example by specifying "systemd.volatile=yes" on the kernel command line.
> This service runs only in the initrd, before the system transitions to the host's root directory.
> Note that this service is not used if "systemd.volatile=state" is used, as in that mode the root
> directory is non-volatile.

Support for this systemd feature has been added in systemd v242 .
https://github.com/systemd/systemd/pull/11243

7 months agofix: let check_vol_slaves_all return 1 when checks on all slaves fail
Coiby Xu [Mon, 26 May 2025 07:34:30 +0000 (15:34 +0800)] 
fix: let check_vol_slaves_all return 1 when checks on all slaves fail

Currently check_vol_slaves_all return 0 even after checks on all slaves
fail. And this leads to an issue that "dracut -hostonly-mode strict"
gets stuck forever because instmods keeps waiting for user input when
it's passed empty argument in the kernel-modules module.

Fixes: c7c8c498 ("dracut-functions.sh: catch all lvm slaves")
Reported-by: Tomáš Bžatek <tbzatek@redhat.com>
Signed-off-by: Coiby Xu <coxu@redhat.com>
7 months agofix(modules): document known module dependencies
Jo Zzsi [Mon, 26 May 2025 00:16:53 +0000 (20:16 -0400)] 
fix(modules): document known module dependencies

Document the known dependencies as comments.

7 months agofix(systemd): make checking for systemd availability consistent
Jo Zzsi [Mon, 26 May 2025 00:21:42 +0000 (20:21 -0400)] 
fix(systemd): make checking for systemd availability consistent

The best way to check if systemd is available is to check for the
systemd dracut module. Most of the existing code does this already,
fix the remaining few places where it does not.

7 months agofix(modules): move more modules with unimportant ordering to 70
Jo Zzsi [Sun, 25 May 2025 23:27:08 +0000 (19:27 -0400)] 
fix(modules): move more modules with unimportant ordering to 70

Dracut library modules - such as fs-lib, img-lib or uefi-lib,
do not need to be ordered differently from other regular modules.

7 months agodocs: document the new defaults set by configure
Jo Zzsi [Thu, 22 May 2025 13:13:06 +0000 (09:13 -0400)] 
docs: document the new defaults set by configure

The new default is set by 62fdf59.

7 months agodocs: promote usage of splash over rhgb
Jo Zzsi [Sun, 25 May 2025 17:13:01 +0000 (13:13 -0400)] 
docs: promote usage of splash over rhgb

This is a documentation only change.

The rhgb command line option will continue to be supported.

Also remove some distribution specific details from the example that
is not essentail for understanding the example.

7 months agofix(livenet): drop stray command call
David Tardon [Wed, 21 May 2025 07:02:46 +0000 (09:02 +0200)] 
fix(livenet): drop stray command call

It was evidently added by a mistake by the original commit, as it makes
no sense.

Fixes a regression from 8b71a80edfca725e8aa281a4f91c55ff6234cc82 .

Fixes #1240

7 months agofix(systemd-repart): copy systemd system drop-in configuration
Jo Zzsi [Wed, 21 May 2025 12:52:06 +0000 (08:52 -0400)] 
fix(systemd-repart): copy systemd system drop-in configuration

Fixes https://github.com/dracut-ng/dracut-ng/issues/1328

7 months agodocs: range 90 - 99 are reserved for out of tree dracut modules
Jo Zzsi [Thu, 22 May 2025 12:44:05 +0000 (08:44 -0400)] 
docs: range 90 - 99 are reserved for out of tree dracut modules

Document the new feature introduced by 2199846 .

7 months agotest: fix the dlopen dependencies test on Gentoo
James Le Cuirot [Fri, 23 May 2025 21:53:26 +0000 (22:53 +0100)] 
test: fix the dlopen dependencies test on Gentoo

systemd needs to have fido2 support enabled at build time for the dlopen
dependency to be present.

Closes: https://github.com/dracut-ng/dracut-ng/issues/1347
Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
7 months agotest: omit fido2 module when testing dlopen dependencies support
James Le Cuirot [Fri, 23 May 2025 21:51:44 +0000 (22:51 +0100)] 
test: omit fido2 module when testing dlopen dependencies support

We check whether libfido2.so.1 is included, but we want it to be because
of systemd's dlopen dependency, not because of the fido2 Dracut module.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
7 months agofeat: set hostonly_cmdline config to no by default
Jo Zzsi [Sun, 18 May 2025 16:30:52 +0000 (12:30 -0400)] 
feat: set hostonly_cmdline config to no by default

This is already the default on Fedora, see

https://github.com/dracut-ng/dracut-ng/blob/main/dracut.conf.d/fedora.conf.example#L44

Fixes: https://github.com/dracut-ng/dracut-ng/issues/1326
7 months agoci: fix integration extra
Jo Zzsi [Wed, 21 May 2025 01:35:33 +0000 (21:35 -0400)] 
ci: fix integration extra

Resolve CI regression introduced by cba9e77 .

7 months agofix(modules): all modules with 99 ordering should have a unique number
Jo Zzsi [Sun, 18 May 2025 11:43:15 +0000 (07:43 -0400)] 
fix(modules): all modules with 99 ordering should have a unique number

This PR does not change the ascending sort order of the modules.

Partially resolve https://github.com/dracut-ng/dracut-ng/issues/538#issuecomment-2487284279

7 months agofix(dracut.sh): don't pass empty string as dir
David Tardon [Tue, 20 May 2025 07:31:52 +0000 (09:31 +0200)] 
fix(dracut.sh): don't pass empty string as dir

That causes dropindirs_sort() to look for .conf files in / due to
expansion:

    for d in "$@"; do
        for i in "$d/"*"$suffix"; do

Fixes #1275

7 months agotest(IMSM): retire testing with dmraid
Jo Zzsi [Mon, 19 May 2025 11:03:27 +0000 (07:03 -0400)] 
test(IMSM): retire testing with dmraid

Neither Debian nor Fedora packages dmraid anymore.

Let's stop focusing on testing dmraid related dracut module anymore.

This is only a CI change; the dmraid dracut module is intentionally
not removed.

Fixes: https://github.com/dracut-ng/dracut-ng/issues/1308
7 months agotest(SYSTEMD-INITRD): demonstrate boot without initqueue
Jo Zzsi [Mon, 19 May 2025 10:08:48 +0000 (06:08 -0400)] 
test(SYSTEMD-INITRD): demonstrate boot without initqueue

After this change initqueue dracut module is no longer used
in the initramfs for this test.

initqueue was added as a dependency of the watchdog module,
which was added as a dependency of the test dracut module.

7 months agorefactor(configure): replace confusing libsystemd error messages
Marcos Mello [Mon, 19 May 2025 15:21:58 +0000 (12:21 -0300)] 
refactor(configure): replace confusing libsystemd error messages

Replace confusing libsystemd error messages (version < 257 or missing development files) during ./configure
with a message clearly indicating that sd-json support is disabled, as it is optional. Previously, users
saw:

```
$ ./configure
Package dependency requirement 'libsystemd >= 257' could not be satisfied.
Package 'libsystemd' has version '252', required version is '>= 257'
Package dependency requirement 'libsystemd >= 257' could not be satisfied.
Package 'libsystemd' has version '252', required version is '>= 257'
```

```
$ ./configure
Package libsystemd was not found in the pkg-config search path.
Perhaps you should add the directory containing `libsystemd.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libsystemd', required by 'virtual:world', not found
Package libsystemd was not found in the pkg-config search path.
Perhaps you should add the directory containing `libsystemd.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libsystemd', required by 'virtual:world', not found
```

7 months agoci: fix syntax error for extra integration tests
Jo Zzsi [Sun, 18 May 2025 11:33:40 +0000 (07:33 -0400)] 
ci: fix syntax error for extra integration tests

7 months agoci: disable failing extra integration tests
Jo Zzsi [Mon, 12 May 2025 15:02:31 +0000 (11:02 -0400)] 
ci: disable failing extra integration tests

These tests are known to fail for weeks, so let's stop running them.

7 months agofix: improve hostonly sloppy mode
Jo Zzsi [Mon, 12 May 2025 01:16:42 +0000 (21:16 -0400)] 
fix: improve hostonly sloppy mode

Resolve regression introduced by 8519dcd.

Fixes #1321 .

7 months agofix(dracut-install): install all suppliers of a supplier's module
Alper Nebi Yasak [Mon, 3 Jun 2024 08:03:32 +0000 (11:03 +0300)] 
fix(dracut-install): install all suppliers of a supplier's module

After installing a module, we get its dependencies and suppliers' paths,
and recurse into two functions that handle installing those. The code
handling a supplier path tries to also handle suppliers-of-suppliers
relations. But when installing a supplier's module, it only recurses to
suppliers for that specific device provided by the module.

Having a subset of its suppliers might not be enough for a module to
work correctly. Recurse into all suppliers of the supplier modules we
are installing.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
7 months agofix(dracut-install): do not limit supplier handling to platform bus
Alper Nebi Yasak [Mon, 3 Jun 2024 07:33:03 +0000 (10:33 +0300)] 
fix(dracut-install): do not limit supplier handling to platform bus

The code that explores a sysfs node for suppliers looks for directories
with a "supplier:platform" prefix. Only the "supplier:" prefix refers to
the devlink relation itself here, the rest is the bus and device name of
the supplier. The bus is not necessarily "platform", but can be "phy",
"regulator", etc.

Correct the searched prefix for sysfs supplier relations to "supplier:"
so we can handle all supplier dependencies to devices, not just those
under the platform bus.

The initial device search is still limited to "/sys/devices/platform".
It theoretically limits the dependencies we check to that directory, but
on device-tree systems it looks like all devices are available there and
we don't miss anything.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
7 months agofix(dracut-install): add sysfs node parents' modules as dependencies
Alper Nebi Yasak [Mon, 3 Jun 2024 07:07:35 +0000 (10:07 +0300)] 
fix(dracut-install): add sysfs node parents' modules as dependencies

While searching a sysfs node for suppliers to add as dependencies, we
also consider suppliers of its parent nodes as dependencies. The code
doing so doesn't explore suppliers-of-suppliers chains, which is meant
to be handled elsewhere. More importantly it misses the parent nodes of
the devices themselves, parents-of-suppliers chains, and their
dependencies; all of which is necessary to get a device working.

Consider the parent nodes of a sysfs node as a supplier dependency when
building the `module_suppliers` hashmap. So the suppliers-of-suppliers
handling elsewhere can work with any combination of parent/supplier
relation.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
7 months agofeat(initqueue): factor out initqueue into its own module
Jo Zzsi [Fri, 31 Jan 2025 14:56:05 +0000 (09:56 -0500)] 
feat(initqueue): factor out initqueue into its own module

This PR allows excluding dracut initqueue module, while
including the base or the dracut-systemd module.

Factoring out functionality into its own module
allows to better control to include or exclude the
functionality.

Co-authored-by: Adam Williamson <awilliam@redhat.com>
7 months agorevert(dracut.install): force hostonly for kernel-install plugin
Jo Zzsi [Tue, 13 May 2025 15:02:47 +0000 (11:02 -0400)] 
revert(dracut.install): force hostonly for kernel-install plugin

revert 17706f9 as now the default is hostonly.

7 months agofeat: set hostonly config by default in configure
Jo Zzsi [Sat, 1 Mar 2025 12:46:53 +0000 (07:46 -0500)] 
feat: set hostonly config by default in configure

Follow-up to https://github.com/dracut-ng/dracut-ng/pull/1158 .

Fix storage test case for zfs.

7 months agotest: sync only relevant files
Benjamin Drung [Mon, 5 May 2025 11:25:37 +0000 (13:25 +0200)] 
test: sync only relevant files

The tests call `sync` without any parameters. This slows down the tests
in case some unrelated disk writes happen somewhere else.

Specify the relevant files that should be synchronized to avoid
unrelated writes to slow down the tests.

Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
7 months agotest: extend TEST-40-SYSTEMD to cover add_dlopen_features
James Le Cuirot [Thu, 27 Mar 2025 19:20:35 +0000 (19:20 +0000)] 
test: extend TEST-40-SYSTEMD to cover add_dlopen_features

Use systemd's fido2 feature because nothing else is likely to pull in
libfido2.so.1. Not all of the containers currently have a new enough
systemd version for this to work. The test will effectively be skipped
until the container includes a new enough systemd-devel and libfido2.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
7 months agofeat(dracut): allow users to choose which dlopen dependencies they want
James Le Cuirot [Wed, 26 Mar 2025 13:02:35 +0000 (13:02 +0000)] 
feat(dracut): allow users to choose which dlopen dependencies they want

Handling dlopen dependencies is nice, but installing these
unconditionally will install more than before rather than less, leading
to bigger images and unhappy users.

This introduces the add_dlopen_features and omit_dlopen_features
configuration options. Modules that are successfully loaded set the
default set of features to add_dlopen_features in the config() function.
Users can request additional features by appending to this variable.
They can also omit features by appending to omit_dlopen_features, which
takes precedence.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
7 months agofeat(dracut): replace ldd with dracut-install --dry-run or header check
James Le Cuirot [Wed, 5 Mar 2025 11:53:18 +0000 (11:53 +0000)] 
feat(dracut): replace ldd with dracut-install --dry-run or header check

One instance checks whether */lib64/* is used by /bin/sh and another
checks whether libusb is used by scdaemon. These can be handled by the
new dracut-install --dry-run option.

find_binary currently uses ldd to check whether a given *.so* is a valid
ELF. ldd exits successfully even when libraries are missing, so it is
sufficient to replace this check with one that looks at the first 4
bytes.

Closes: https://github.com/dracut-ng/dracut-ng/issues/338
Closes: https://github.com/dracut-ng/dracut-ng/issues/1257
Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
7 months agofeat(dracut-install): add --dry-run option to replace external ldd usage
James Le Cuirot [Tue, 4 Mar 2025 17:21:27 +0000 (17:21 +0000)] 
feat(dracut-install): add --dry-run option to replace external ldd usage

To remove the remaining use of ldd, we need a way to show which
libraries a binary requires. I initially considered adding another small
tool, sharing code with dracut-install, but then I realised that adding
a --dry-run option to dracut-install would also meet that need with a
lot less effort.

It simply shows what would be installed and doesn't require you to
specify a destination directory. It is similar to the existing --logdir
option, but that cannot log to stdout and includes additional output.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
7 months agofeat(dracut-install): extend new ELF parsing code to replace ldd calls
James Le Cuirot [Tue, 4 Mar 2025 11:09:32 +0000 (11:09 +0000)] 
feat(dracut-install): extend new ELF parsing code to replace ldd calls

Now that dracut-install has its own ELF parsing code to handle dlopen
dependencies, it is only a small additional step to also handle
traditional DT_NEEDED dependencies, removing the need to call ldd, which
is not cross-friendly.

This avoids the earlier issue seen with musl in #1087.

We should no longer directly install libsystemd*.so because
libsystemd-core does not have the RUNPATH to find libsystemd-shared by
itself. Both get pulled in by the main systemd binary anyway. ldd had
the same issue, dracut-install silently ignored the failure.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
7 months agofeat(dracut-install): parse ELF .note.dlopen entries for extra deps
James Le Cuirot [Tue, 18 Feb 2025 17:24:05 +0000 (17:24 +0000)] 
feat(dracut-install): parse ELF .note.dlopen entries for extra deps

Unlike traditional DT_NEEDED dependencies, there has not been a way to
determine what libraries an ELF may dlopen until recently. systemd has
documented a convention to declare such dependencies using JSON in the
ELF metadata. See https://systemd.io/ELF_DLOPEN_METADATA/ for details.

This metadata references sonames rather than full paths, so Dracut needs
to determine the full paths by itself. It cannot use ldd to do this as
that relies on DT_NEEDED. ldconfig can show the paths for all sonames in
the cache, but that relies on the cache having already been generated,
it isn't cross-friendly, and musl doesn't even have ldconfig. It
therefore makes sense for Dracut to parse the ELF headers directly. This
also paves the way for removing the dependency on ldd entirely, making
Dracut more cross-friendly as a whole.

To avoid adding an entirely new dependency, the JSON parsing is done by
libsystemd's sd-json API. This has been exposed since systemd v257. If
libsystemd is too old or not present at all, then this dlopen handling
is simply skipped. This is currently not an issue for non-systemd
distributions as systemd is the only project using this convention. If
that were to change, libsystemd can still be used without the rest of
systemd, as demonstrated by Gentoo.

The metadata itself has only been included by systemd since v256. If an
earlier version is detected, Dracut will unconditionally install the
same libraries that it did before.

There are different structs for 32-bit and 64-bit ELF headers, so this
new code makes heavy use of C macros to avoid a lot of code duplication.
One macro is also used heavily for endian conversion, as almost every
field needs to be adjusted.

See the code comments for the remaining details.

Closes: https://github.com/dracut-ng/dracut-ng/issues/154
Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>