Re: [OE-core] [PATCH v3 04/11] core-image-initramfs-boot: add option to build systemd based initrd

Mikko Rapeli
2025-04-10T13:06:00Z

Hi,

On Thu, Apr 10, 2025 at 01:45:13PM +0100, Richard Purdie wrote:
> On Fri, 2025-04-04 at 19:29 +0300, Mikko Rapeli via lists.openembedded.org wrote:
> > If "systemd-initramfs" is in DISTRO_FEATURES then convert
> > core-image-initramfs-boot from shell scripts to systemd.
> > The resulting initramfs is much bigger than shell script one but
> > supports much more features like disk encryption and TPM devices.
> > Also includes udev which can load any drivers needed to mount
> > rootfs.
> >
> > Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
> > ---
> > ï¿½.../images/core-image-initramfs-boot.bbï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ | 20 ++++++++++++++++---
> > ï¿½1 file changed, 17 insertions(+), 3 deletions(-)
> >
> > diff --git a/meta/recipes-core/images/core-image-initramfs-boot.bb b/meta/recipes-core/images/core-image-initramfs-boot.bb
> > index 7258944751..c66c28db76 100644
> > --- a/meta/recipes-core/images/core-image-initramfs-boot.bb
> > +++ b/meta/recipes-core/images/core-image-initramfs-boot.bb
> > @@ -4,7 +4,23 @@ LICENSE = "MIT"
> > ï¿½
> > ï¿½INITRAMFS_SCRIPTS ?= "initramfs-framework-base initramfs-module-udev"
> > ï¿½
> > -PACKAGE_INSTALL = "${INITRAMFS_SCRIPTS} ${VIRTUAL-RUNTIME_base-utils} base-passwd"
> > +inherit image
> > +
> > +PACKAGE_INSTALL = " \
> > +ï¿½ï¿½ï¿½ ${VIRTUAL-RUNTIME_base-utils} \
> > +ï¿½ï¿½ï¿½ ${@bb.utils.contains('DISTRO_FEATURES', 'systemd-initramfs', ' \
> > +ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ base-files \
> > +ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ coreutils \
> > +ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ e2fsprogs-mke2fs \
> > +ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ os-release-initrd \
> > +ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ util-linux-blkid \
> > +ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ util-linux-mount \
> > +ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ util-linux-umount \
> > +ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ ${VIRTUAL-RUNTIME_init_manager} \
> > +ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ ${VIRTUAL-RUNTIME_dev_manager} \
> > +ï¿½ï¿½ï¿½ ', '${INITRAMFS_SCRIPTS}', d)} \
> > +ï¿½ï¿½ï¿½ base-passwd \
> > +"
> > ï¿½
> > ï¿½# Ensure the initramfs only contains the bare minimum
> > ï¿½IMAGE_FEATURES = ""
> > @@ -18,5 +34,3 @@ IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}"
> > ï¿½IMAGE_NAME_SUFFIX ?= ""
> > ï¿½IMAGE_ROOTFS_SIZE = "8192"
> > ï¿½IMAGE_ROOTFS_EXTRA_SPACE = "0"
> > -
> > -inherit image
>
> Given this effectively completely changes the image, would we be better
> just defining a different image recipe for the systemd based initramfs?

I don't know. At least for testing purposes switching with
DISTRO_FEATURE is relatively easy. Though exact same thing
would work with INITRAMFS_IMAGE variable. I just started
with this approach but can change it if you prefer a
separate recipe.

For upper level layers it may be tricky if they need to modify
something but need to deal with two different
image recipe names and can't just have all in a single
bbappend.

Cheers,

-Mikko