I'm creating distribution using Yocto. The idea is to boot into initramfs, change disk parameters e.g. enable encryption. I've created initramfs image my-initramfs.bb:
LICENSE = "CLOSED"
inherit core-image
INITRAMFS_SCRIPTS ?= "\
initramfs-framework-base \
initramfs-module-setup-live \
initramfs-module-udev \
initramfs-module-install \
initramfs-module-install-efi \
"
VIRTUAL-RUNTIME_dev_manager ?= "systemd"
PACKAGE_INSTALL = "\
initrd-setup \
systemd-conf \
packagegroup-core-boot \
dropbear \
${VIRTUAL-RUNTIME_base-utils} \
${VIRTUAL-RUNTIME_dev_manager} \
${INITRAMFS_SCRIPTS} \
base-passwd \
${ROOTFS_BOOTSTRAP_INSTALL} \
"
IMAGE_FSTYPES:append = " ${INITRAMFS_FSTYPES} "
Then add configuration in conf/local.conf:
INITRAMFS_IMAGE_BUNDLE = "1"
INITRAMFS_IMAGE = "my-initramfs"
Then I built core-image-base.
When I run my-initramfs in qemu, it is executing everything as planned.
[ 1.390237] Run /sbin/init as init process
[ 1.401400] usb 1-1: new high-speed USB device number 2 using xhci_hcd
[ 1.564060] input: QEMU QEMU USB Tablet as /devices/platform/4010000000.pcie/pci0000:00/0000:00:04.0/usb1/1-1/1-1:1.0/0003:0627:0001.0001/input/input0
[ 1.565226] hid-generic 0003:0627:0001.0001: input: USB HID v0.01 Mouse [QEMU QEMU USB Tablet] on usb-0000:00:04.0-1/input0
[ 1.609303] systemd[1]: systemd 255.1^ running in system mode (-PAM -AUDIT -SELINUX -APPARMOR +IMA -SMACK +SECCOMP -GCRYPT -GNUTLS -OPENSSL +ACL +BLKID -CURL -ELFUTILS -FIDO2 -IDN2 -IDN -IPTC +KMOD -LIBCRYPTSETUP +LIBFDISK -PCRE2 -PWQUALITY -P11KIT -QRENCODE -TPM2 -BZIP2 -LZ4 -XZ -ZLIB +ZSTD -BPF_FRAMEWORK +XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified)
[ 1.611361] systemd[1]: Detected virtualization qemu.
[ 1.611927] systemd[1]: Detected architecture arm64.
[ 1.612263] systemd[1]: Running in initrd.
[ 1.625055] systemd[1]: Hostname set to <qemuarm64>.
When I run core-image-base, expecting that initramfs will be called before mounting disks - it just boots, no initramfs involved.
[ 1.362359] Run /sbin/init as init process
[ 1.385213] usb 1-1: new high-speed USB device number 2 using xhci_hcd
[ 1.552707] input: QEMU QEMU USB Tablet as /devices/platform/4010000000.pcie/pci0000:00/0000:00:04.0/usb1/1-1/1-1:1.0/0003:0627:0001.0001/input/input0
[ 1.553794] hid-generic 0003:0627:0001.0001: input: USB HID v0.01 Mouse [QEMU QEMU USB Tablet] on usb-0000:00:04.0-1/input0
[ 1.571365] systemd[1]: systemd 255.1^ running in system mode (-PAM -AUDIT -SELINUX -APPARMOR +IMA -SMACK +SECCOMP -GCRYPT -GNUTLS -OPENSSL +ACL +BLKID -CURL -ELFUTILS -FIDO2 -IDN2 -IDN -IPTC +KMOD -LIBCRYPTSETUP +LIBFDISK -PCRE2 -PWQUALITY -P11KIT -QRENCODE -TPM2 -BZIP2 -LZ4 -XZ -ZLIB +ZSTD -BPF_FRAMEWORK +XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified)
[ 1.573247] systemd[1]: Detected virtualization qemu.
[ 1.573598] systemd[1]: Detected architecture arm64.
[ 1.584784] systemd[1]: Hostname set to <qemuarm64>.
I need to execute scripts before disks are mounted to manipulate disks on raspberrypi. Maybe I'm doing something wrong, and I should do something completely different?