Jo Zzsi [Tue, 29 Jul 2025 17:59:35 +0000 (13:59 -0400)]
fix(base): base module failure if root password is already set
Replace sed with grep and simplify logic by removing a conditional
and if needed simply copying the line from the host shadow file to
the initramfs shadow file.
Jo Zzsi [Sun, 13 Jul 2025 00:31:12 +0000 (20:31 -0400)]
fix(systemd-sysusers): maintain users and groups
Currently dracut deletes entries for users and groups created
by systemd-sysusers.
This PR maitaines users and groups created by systemd-sysusers
and merges root password from the host with the shadow file
created by systemd-sysusers.
Add test assertion to check if systemd-coredump user is present,
which is expected on a systemd-enabled system.
Allow the owner to read and write /etc/shadow and /etc/gshadow
in the initramfs.
This fixes a permission error during dracut when it's not run
as root:
Jo Zzsi [Thu, 3 Jul 2025 13:59:05 +0000 (09:59 -0400)]
test: remove unnecessary drivers from test dracut modules
Fixes: https://github.com/dracut-ng/dracut-ng/issues/1324
To increase test coverage for kernel-modules and instead
of hard-coding required Linux kernel modules,
use the kernel-modules dracut module instead.
Jo Zzsi [Tue, 15 Jul 2025 16:26:15 +0000 (12:26 -0400)]
fix(generic.conf): increase ordering for generic.conf
In the unlikely case that both hostonly and generic config
is installed generic should take an explicit precedence.
Currently both hostonly and generic config has the same ordering
number (10), so the precedence is based on the rest of the name
and not based on the ordering number.
Now that hostonly is the default configuration that gets installed
by default, it is particularly important for generic has higher
precedence as generic is likely only installed as an opt-in
configuration and not as the "default".
Benjamin Drung [Sun, 20 Jul 2025 12:14:00 +0000 (14:14 +0200)]
feat(dracut): drop DRACUT_PATH and rely on PATH
This reverts commit eab9b75c8a9b ("dracut.sh: add DRACUT_PATH").
Drop `DRACUT_PATH` and rely on `PATH` instead to avoid user confusion
and behave like most other programs.
To avoid failing on misconfiguration (e.g. when `/usr/sbin` is not in
`PATH`), ensure that the common default paths `/usr/sbin`, `/usr/bin`,
`/sbin`, and `/bin` are included in `PATH`.
Jo Zzsi [Sat, 19 Jul 2025 20:13:20 +0000 (16:13 -0400)]
test: compute VMLINUZ in run-qemu only when it is needed
Currently VMLINUZ is computed and set even when it is not needed
(e.g. for test 80). Move the computation to run-qemu instead
and only set it when needed.
Jo Zzsi [Sat, 19 Jul 2025 19:54:28 +0000 (15:54 -0400)]
test: prefer testing dracut over testing ukify
Dracut can call ukify when available to generate UKI
(see acfddd69f). Prefer testing this flow, over testing calling ukify
directly from the test-case.
This change also remove the need for test-cases to have direct access
to VMLINUZ variable.
Jo Zzsi [Sat, 19 Jul 2025 03:05:58 +0000 (23:05 -0400)]
fix(dracut): consolidate reporting running in a container
dinfo call to report running in a container does not work as expected
as dinfo is not yet defined in the first code block.
In addition we're already reporting running in a container in some
other conditions, which would lead to reporting it twice.
Consolidate reporting running in a container into one single place
and make it work, and reporting is as information and not as a warning
as using dracut inside container is common.
Reordered two code blocks to enable the usage of dinfo to simplify
reporting.
Benjamin Drung [Sat, 19 Jul 2025 08:30:19 +0000 (10:30 +0200)]
feat(dracut): support SOURCE_DATE_EPOCH
`SOURCE_DATE_EPOCH` is a standardised environment variable that
distributions can set centrally and have build tools consume this in
order to produce reproducible output (see
https://reproducible-builds.org/docs/source-date-epoch/).
Enable reproducible builds when `SOURCE_DATE_EPOCH` is set and use this
timestamp when clamping the mtime.
Marc Herbert [Tue, 15 Jul 2025 22:33:53 +0000 (22:33 +0000)]
docs(test): add new test/README.md
As discussed on July 14th in #1268, add a new and small test/README.md
file for convenience. This is just a list of pointers/shortcuts to
existing documentation. Add enough English around the pointers to make
it easy to find the new location even if stuff moves. Even when pointers
go out of date, it makes a big difference to have an idea of what you're
looking for - and that it even exists in the first place!
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Jo Zzsi [Wed, 16 Jul 2025 19:36:00 +0000 (15:36 -0400)]
fix: increase deteminism by not relying on the default sorting from ls
In the unlikely case where there are several kernels installed on the host
and kernel is not specified on the command line, let's not rely
on the the default sorting from ls and call ls with -v for natural
sort of (version) numbers within text.
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.
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.
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.
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.
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
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.
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).
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.
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.
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.
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>
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.
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:
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>
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.
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.
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
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>
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.