Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 935548 - sys-kernel/dracut: libkmod missing in initramfs w/ sys-apps/systemd-256 on arm64 (src_test() in kernel-install.eclass doesn't boot)
Summary: sys-kernel/dracut: libkmod missing in initramfs w/ sys-apps/systemd-256 on ar...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: ARM64 Linux
: Normal normal
Assignee: Distribution Kernel Project
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2024-07-05 13:40 UTC by Michał Górny
Modified: 2024-07-16 16:52 UTC (History)
7 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
kmod.patch (kmod.patch,1.57 KB, text/plain)
2024-07-15 10:28 UTC, Alexander Tsoy
Details
kmod.patch (kmod.patch,1.64 KB, text/plain)
2024-07-15 11:05 UTC, Alexander Tsoy
Details
kmod.patch (kmod.patch,1.65 KB, text/plain)
2024-07-15 11:08 UTC, Alexander Tsoy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2024-07-05 13:40:53 UTC
While building today's kernels, I've noticed that they fail to boot on arm64.

The last lines of output are:

[   14.103927] dracut: Gentoo-2.15
Starting systemd-udevd version 256
[  555.757460] dracut Warning: Could not boot.
dracut Warning: Could not boot.
[  556.175725] dracut Warning: /dev/disk/by-label/groot does not exist
dracut Warning: /dev/disk/by-label/groot does not exist


i.e. udev starts, then dracut waits for a long time and then abandons all hope.  I suspect block devices don't appear.

I've reproduced this on arm64 but not amd64.  It happens with systemd-256 but not 255.  I don't know about ppc64le nor x86 since these two were built with -255.

I'd really appreciate if someone could quickly test regenerating initramfs (i.e. `emerge --config`) against systemd-256 on arm64 and checking if it boots, so we'd know whether it's specific to our src_test() configuration and/or qemu, or affects real systems as well.
Comment 1 Anthony Mendez 2024-07-06 06:45:34 UTC
Was able to reproduce!

- VM Host: Windows 10, VirtualBox v7.0.18.
- Kernel: sys-kernel/gentoo-kernel-bin-6.6.30
- SystemD: sys-apps/systemd-256.1-r3

Same behavior, cannot find the root filesystem.
Comment 2 Anthony Mendez 2024-07-06 06:48:58 UTC
Forgot to mention, host and vm are both amd64.
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2024-07-06 08:15:16 UTC
(In reply to Anthony Mendez from comment #2)
> Forgot to mention, host and vm are both amd64.

So it happens on amd64 too?  That's weird, because src_test() worked there, and it's the same setup AFAIR...
Comment 4 Anthony Mendez 2024-07-07 07:35:27 UTC
I rolled back systemd to 255.7-r1 and emerge --config gentoo-kernel-bin again and then the vm booted again with no issues.
Comment 5 Mike Gilbert gentoo-dev 2024-07-07 14:56:21 UTC
Unable to reproduce here.

~amd64
sys-kernel/dracut-102
sys-apps/systemd-256.1-r3
sys-kernel/vanilla-kernel-6.6.35

I am able to boot real hardware using grub, and src_test in vanilla-kernel works fine.
Comment 6 Nowa Ammerlaan gentoo-dev 2024-07-14 11:02:33 UTC
Could someone who can reproduce this please re-test with Dracut 103?
Comment 7 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2024-07-14 16:39:28 UTC
(In reply to Andrew Nowa Ammerlaan from comment #6)
> Could someone who can reproduce this please re-test with Dracut 103?

Still happens.  I have exported the docker image, and will try booting it interactively in qemu.
Comment 8 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2024-07-14 17:05:35 UTC
Ok, so got into the debug shell, and there were no block devices at all.  I had to manually:

$ modprobe virtio_blk

for them to appear.  So apparently that's what stopped happening in systemd-256.
Comment 9 Alexander Tsoy 2024-07-14 22:28:35 UTC
Maybe missing libkmod.so.2 in initramfs due to [1]?

[1] https://github.com/systemd/systemd/commit/3abc3671f56d0d124c93acef20f7e7a1c8efe72b
Comment 10 Alexander Tsoy 2024-07-14 23:05:59 UTC
(In reply to Alexander Tsoy from comment #9)
> Maybe missing libkmod.so.2 in initramfs due to [1]?
Please ignore. dracut-102 and -103 should handle this.
Comment 11 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2024-07-15 06:25:49 UTC
If you want to look at it, the last set is archived at:

https://dev.gentoo.org/~mgorny/tmp/kernetest.tar (45M)

(warning: no top-level directory)

vmlinuz.efi is the kernel, initrd is the initramfs, fs.img is the test disk image.  run.sh is the original script used to run tests; you will need to adjust paths in it.

(In reply to Alexander Tsoy from comment #9)
> Maybe missing libkmod.so.2 in initramfs due to [1]?
> 
> [1]
> https://github.com/systemd/systemd/commit/
> 3abc3671f56d0d124c93acef20f7e7a1c8efe72b

That's an interesting suggestion.

$ lsinitrd initrd | grep kmod
-rwxr-xr-x   1 root     root       133024 lip 14 17:55 usr/bin/kmod
lrwxrwxrwx   1 root     root            4 lip 14 18:10 usr/bin/modprobe -> kmod
lrwxrwxrwx   1 root     root            4 lip 14 18:10 usr/bin/rmmod -> kmod

So indeed it doesn't seem to be there.  Curious enough, modprobe(1) works, so... kmod(1) doesn't require it?
Comment 12 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2024-07-15 07:41:34 UTC
And indeed, with 255 the initramfs includes libkmod:

-rwxr-xr-x   1 root     root       132832 Jul 14 17:27 usr/lib64/libkmod.so.2.4.2
lrwxrwxrwx   1 root     root           16 Jul 15 06:39 usr/lib64/libkmod.so.2 -> libkmod.so.2.4.2
lrwxrwxrwx   1 root     root           16 Jul 15 06:39 usr/lib64/libkmod.so -> libkmod.so.2.4.2
Comment 13 Alexander Tsoy 2024-07-15 08:02:09 UTC
(In reply to Michał Górny from comment #11)
> If you want to look at it, the last set is archived at:
> 
> https://dev.gentoo.org/~mgorny/tmp/kernetest.tar (45M)

Looks like a typo there. Should be
https://dev.gentoo.org/~mgorny/tmp/kerntest.tar

> So indeed it doesn't seem to be there.  Curious enough, modprobe(1) works,
> so... kmod(1) doesn't require it?

Yes, kmod statically links to libkmod.

That's interesting.. Initramfs is generated with dracut-103 which contains a fix [1]:

$ lsinitrd initrd usr/lib/initrd-release | grep ^DRACUT_VERSION
DRACUT_VERSION="103"

but there is no libkmod indeed:

$ lsinitrd initrd | grep libkmod
$ 

[1] https://github.com/dracut-ng/dracut-ng/commit/04b362d713235459cff1f370efb4cd5e36e4a358
Comment 14 Alexander Tsoy 2024-07-15 08:05:08 UTC
And I wonder how this works on amd64
Comment 15 Nowa Ammerlaan gentoo-dev 2024-07-15 09:09:22 UTC
> [1] https://github.com/dracut-ng/dracut-ng/commit/04b362d713235459cff1f370efb4cd5e36e4a358

This fix changes the systemd dracut module, but we explicitly omit that module in src_test. Systemd seems to have some additional conditions that need to be fulfilled for it to consider the root partition valid, at the time I could not figure out what exactly was missing so instead simply omitted the module.

Presumably if we fix booting the src_test with the systemd module included we also fix this problem (due to [1]). But then still it seems to me that there is some additional bug in Dracut that needs fixing upstream.

What still puzzles me though is why this bug is arch dependent.
Comment 16 Nowa Ammerlaan gentoo-dev 2024-07-15 09:22:21 UTC
Does this resolve the issue on your end?

diff --git a/modules.d/01systemd-udevd/module-setup.sh b/modules.d/01systemd-udevd/module-setup.sh
index 8d4a8b90..f3a24807 100755
--- a/modules.d/01systemd-udevd/module-setup.sh
+++ b/modules.d/01systemd-udevd/module-setup.sh
@@ -71,6 +71,8 @@ install() {

# Install required libraries.
_arch=${DRACUT_ARCH:-$(uname -m)}
-    inst_libdir_file {"tls/$_arch/",tls/,"$_arch/",}"libudev.so.*"
+    inst_libdir_file \
+        {"tls/$_arch/",tls/,"$_arch/",}"libkmod.so*" \
+        {"tls/$_arch/",tls/,"$_arch/",}"libudev.so.*"

}
Comment 17 Alexander Tsoy 2024-07-15 09:37:52 UTC
(In reply to Andrew Nowa Ammerlaan from comment #16)
> diff --git a/modules.d/01systemd-udevd/module-setup.sh
> b/modules.d/01systemd-udevd/module-setup.sh
> index 8d4a8b90..f3a24807 100755
> --- a/modules.d/01systemd-udevd/module-setup.sh
> +++ b/modules.d/01systemd-udevd/module-setup.sh
> @@ -71,6 +71,8 @@ install() {
> 
> # Install required libraries.
> _arch=${DRACUT_ARCH:-$(uname -m)}
> -    inst_libdir_file {"tls/$_arch/",tls/,"$_arch/",}"libudev.so.*"
> +    inst_libdir_file \
> +        {"tls/$_arch/",tls/,"$_arch/",}"libkmod.so*" \
> +        {"tls/$_arch/",tls/,"$_arch/",}"libudev.so.*"
> 
> }
Note that systemd-udevd module depends on systemd module. I suspect that libkmod.so should also be installed by udev-rules module. Otherwise openrc users will also face the same problem when sys-apps/systemd-utils is updated.
Comment 18 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2024-07-15 09:59:17 UTC
0.036 patching file /usr/lib/dracut/modules.d/01systemd-udevd/module-setup.sh
0.036 Hunk #1 FAILED at 71.
0.037 1 out of 1 hunk FAILED -- saving rejects to file /usr/lib/dracut/modules.d/01systemd-udevd/module-setup.sh.rej

Of course, it's possible that I've messed it up while trying to fix it after it being messed up by Bugzilla paste.
Comment 19 Alexander Tsoy 2024-07-15 10:19:40 UTC
I can reproduce on amd64

$ sudo lsinitrd | grep libkmod
-rwxr-xr-x   1 root     root       104456 Jun 22 19:26 usr/lib64/libkmod.so.2.4.2
lrwxrwxrwx   1 root     root           16 Jul 15 11:22 usr/lib64/libkmod.so.2 -> libkmod.so.2.4.2
lrwxrwxrwx   1 root     root           16 Jul 15 11:22 usr/lib64/libkmod.so -> libkmod.so.2.4.2
$ sudo dracut -f -o " systemd "
...
$ sudo lsinitrd | grep libkmod
$

(In reply to Andrew Nowa Ammerlaan from comment #16)
> Does this resolve the issue on your end?
> 
> diff --git a/modules.d/01systemd-udevd/module-setup.sh
> b/modules.d/01systemd-udevd/module-setup.sh
> index 8d4a8b90..f3a24807 100755
> --- a/modules.d/01systemd-udevd/module-setup.sh
> +++ b/modules.d/01systemd-udevd/module-setup.sh
> @@ -71,6 +71,8 @@ install() {
> 
> # Install required libraries.
> _arch=${DRACUT_ARCH:-$(uname -m)}
> -    inst_libdir_file {"tls/$_arch/",tls/,"$_arch/",}"libudev.so.*"
> +    inst_libdir_file \
> +        {"tls/$_arch/",tls/,"$_arch/",}"libkmod.so*" \
> +        {"tls/$_arch/",tls/,"$_arch/",}"libudev.so.*"
> 
> }
And this patch doesn't help here. The only module that installs udevd when systemd module is omitted is udev-rules. I'll prepare a patch.
Comment 20 Alexander Tsoy 2024-07-15 10:28:57 UTC
Created attachment 897660 [details]
kmod.patch
Comment 21 Alexander Tsoy 2024-07-15 11:05:54 UTC
Created attachment 897661 [details]
kmod.patch

Added a guard to prevent installing same things multiple times
Comment 22 Alexander Tsoy 2024-07-15 11:08:51 UTC
Created attachment 897662 [details]
kmod.patch

Fixed copy-paste error
Comment 23 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2024-07-15 11:11:06 UTC
(In reply to Alexander Tsoy from comment #20)
> Created attachment 897660 [details]
> kmod.patch

I can confirm that this one fixed the issue for me.
Comment 24 Alexander Tsoy 2024-07-15 11:44:30 UTC
https://github.com/dracut-ng/dracut-ng/pull/507
Comment 25 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-07-15 11:45:18 UTC
Many thanks!
Comment 26 Larry the Git Cow gentoo-dev 2024-07-16 16:52:45 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=286138c22e437f22d1ed42726c4988745d8cf5cf

commit 286138c22e437f22d1ed42726c4988745d8cf5cf
Author:     Andrew Ammerlaan <andrewammerlaan@gentoo.org>
AuthorDate: 2024-07-16 16:51:56 +0000
Commit:     Andrew Ammerlaan <andrewammerlaan@gentoo.org>
CommitDate: 2024-07-16 16:51:56 +0000

    sys-kernel/dracut: backport fix for systemd 256
    
    Closes: https://bugs.gentoo.org/935548
    Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>

 .../{dracut-103.ebuild => dracut-103-r1.ebuild}    |  2 ++
 .../files/dracut-103-systemd-udev-256-kmod.patch   | 41 ++++++++++++++++++++++
 2 files changed, 43 insertions(+)