[PATCH v3 00/11] systemd based initrd and modular kernel support

Mikko Rapeli
2025-04-04T16:29:54Z

systemd based initrd supports more security, encryption etc features
than custom shell script ones but oe-core lacks support for it.
Convert core-image-initramfs-boot to create systemd based initrd
if "systemd-initramfs" is set in DISTRO_FEATURES. Includes a test
for this initrd to mount rootfs via Unified Kernel Image uki.py.

Sadly the boot time is really slow, e.g. over 30 seconds with
systemd based initrd. One of the major reasons is the large
amount of kernel modules built into the linux-yocto kernel and
processing of their udev events in userspace. Thus add
kernel-initrd-modules meta package to easily install
subset of all kernel modules to initrd. The subset
supports "mount rootfs from any block device" but
doesn't include graphics, UBS etc support. Without this
generated meta package, initrd recipe needs to manually define
which exact kernel modules to include which breaks if
those modules are built into the kernel. Thus the initrd
becomes machine and kernel config specific and hard to maintain.
With this meta package a generic initrd can be created.

Separate changes to linux-yocto compile a lot more drivers
as modules but they depend on these initrd changes.

v1: https://lists.openembedded.org/g/openembedded-core/message/212832

v2: split initrd size reduction and kernel modules addition
to separate commits, added packages exclicitly back to fix
rootfs mount visible as wic selftest failures,
fixed wic bugs which resulted in broken boot due to missing
EFI bootloader binaries in some builds, moved
"systemd: use serial-getty-generator on genericarm64" to separate
series since it's not strictly needed and goes to a different mailing
list

v3: enable "efi" support in systemd by default not via MACHINE_FEATURES,
disable kernel-initrd-modules meta package generation if
KERNEL_INITRD_MODULES_REGEX is not set at all, keeping
default KERNEL_INITRD_MODULES_REGEX in classes to support
external kernel recipes (which could be compatible with default
images to e.g. run upstream tests), tested (with pmem and
modular kernel RFC patches sent out separately) using genericarm64
machine config on:
qemu u-boot https://ledge.validation.linaro.org/scheduler/job/106701
qemu edk2 https://ledge.validation.linaro.org/scheduler/job/106703
AMD zcu102 https://ledge.validation.linaro.org/scheduler/job/106702
AMD kv260 https://ledge.validation.linaro.org/scheduler/job/106700
rpi4 https://ledge.validation.linaro.org/scheduler/job/106705

Mikko Rapeli (11):
systemd: enable efi support by default
uki.bbclass: drop serial console from kernel command line
kernel.bbclass: add kernel-initrd-modules meta package
core-image-initramfs-boot: add option to build systemd based initrd
core-image-initramfs-boot: don't install RRECOMMENDS to reduce size
core-image-initramfs-boot: install kernel-initrd-modules by default
oeqa selftest uki.py: add aarch64/arm test with systemd based initrd
test_efi_plugin_plain_systemd-boot: don't set console
image_types_wic.bbclass: capture verbose wic output by default
wic bootimg-efi.py: fail build if no binaries installed
image_types_wic.bbclass: depend on grub-efi and systemd-boot on
aarch64, systemd-boot on arm

.../test_efi_plugin_plain_systemd-boot.wks | 2 +-
meta/classes-recipe/image_types_wic.bbclass | 4 +-
.../kernel-module-split.bbclass | 48 ++++++++++++
meta/classes-recipe/kernel.bbclass | 5 +-
meta/classes-recipe/module.bbclass | 37 +++++++++
meta/classes-recipe/uki.bbclass | 2 +-
meta/lib/oeqa/selftest/cases/uki.py | 76 +++++++++++++++++++
.../images/core-image-initramfs-boot.bb | 32 +++++++-
meta/recipes-core/systemd/systemd_257.4.bb | 3 +-
scripts/lib/wic/plugins/source/bootimg-efi.py | 3 +
10 files changed, 203 insertions(+), 9 deletions(-)

--
2.43.0