Skip to contentSkip to conversation

initramfs is isn't trying to mount the actual rootfs and is not doing switch_root #kernel #yocto

DISCUSSION greymattr 2 participants 2 messages Jan 22, 2024 – Jan 23, 2024

lore
Share & tools
lore

greymattr

author
#0 lore raw

I am using the kirkstone yocto build to build a firmware image that has a kernel with initramfs, and a ext4 root file system on an emmc partition.

After booting up the kernel doesn't mount the device passed to the kernel as the "root=" parameter and doesn't switch_root, it just mounts everything to ram.

In my initramfs image recipe I have set:

PACKAGE_INSTALL = "util-linux udev busybox base-passwd ${VIRTUAL-RUNTIME_base-utils} ${VIRTUAL-RUNTIME_dev_manager} ${ROOTFS_BOOTSTRAP_INSTALL}"

and I was under the impression that the ${ROOTFS_BOOTSTRAP_INSTALL} should handle the switch_root portion of the boot after the initramfs loads, but that is not happening.

Is there a different package I need to add to the PACKAGE_INSTALL to allow the real root partition to be mounted, and switch_root to occur?

#1 lore raw
Quoted 9 lines · greymattr via lists.yoctoproject.org

I am using the kirkstone yocto build to build a firmware image that has a kernel with initramfs, and a ext4 root file system on an emmc partition. After booting up the kernel doesn't mount the device passed to the kernel as the "root=" parameter and doesn't switch_root, it just mounts everything to ram.

In my initramfs image recipe I have set:
PACKAGE_INSTALL = "util-linux udev busybox base-passwd ${VIRTUAL-RUNTIME_base-utils} ${VIRTUAL-RUNTIME_dev_manager} ${ROOTFS_BOOTSTRAP_INSTALL}"

and I was under the impression that the ${ROOTFS_BOOTSTRAP_INSTALL} should handle the switch_root portion of the boot after the initramfs loads, but that is not happening. Is there a different package I need to add to the PACKAGE_INSTALL to allow the real root partition to be mounted, and switch_root to occur?

$ bitbake-getvar -r core-image-minimal  —value ROOTFS_BOOTSTRAP_INSTALL
ROOTFS_BOOTSTRAP_INSTALL="run-postinsts”

ROOTFS_BOOTSTRAP_INSTALL is the list of recipes that also need to be installed to handle rootfs stuff, so typically it’s either empty or includes run-postinsts to run any postinstall scripts that couldn’t be ran on the build host.

The initramfs-framework recipes have various pieces of the typical initramfs setup in (scan for devices, mount, pivot, etc) and these are used in core-image-minimal-initramfs. I actually recently added to master a slimmer image which _just_ finds and pivots:

https://git.yoctoproject.org/poky/tree/meta/recipes-core/images/core-image-initramfs-boot.bb

Ross