diff mbox series

initramfs-framework: mount /run and move to rootfs before switch_root

Message ID 20250819005605.2463139-1-ricardo@foundries.io
State New
Headers show
Series initramfs-framework: mount /run and move to rootfs before switch_root | expand

Commit Message

Ricardo Salveti Aug. 19, 2025, 12:56 a.m. UTC
Mount /run as tmpfs during early init and include it in the set of
mounts moved to $ROOTFS_DIR prior to exec switch_root.

Having /run available early lets initramfs modules stamp state that can
later influence systemd service jobs, since systemd will reuse the mount
point instead of creating a new one during boot.

This is particularly useful with ostree, as it uses /run/ostree-booted
as way to describe that the rootfs comes from an ostree deployment.

Signed-off-by: Ricardo Salveti <ricardo@foundries.io>
---
 meta/recipes-core/initrdscripts/initramfs-framework/finish | 3 ++-
 meta/recipes-core/initrdscripts/initramfs-framework/init   | 4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/finish b/meta/recipes-core/initrdscripts/initramfs-framework/finish
index 716c2f44af..21eaa57393 100755
--- a/meta/recipes-core/initrdscripts/initramfs-framework/finish
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/finish
@@ -35,10 +35,11 @@  finish_run() {
 			mount -n --move "$dir" "${ROOTFS_DIR}/media/${dir##*/}"
 		done
 
-		debug "Moving /dev, /proc and /sys onto rootfs..."
+		debug "Moving /dev, /proc, /sys and /run onto rootfs..."
 		mount --move /dev $ROOTFS_DIR/dev
 		mount --move /proc $ROOTFS_DIR/proc
 		mount --move /sys $ROOTFS_DIR/sys
+		mount --move /run $ROOTFS_DIR/run
 
 		cd $ROOTFS_DIR
 		exec switch_root $ROOTFS_DIR ${bootparam_init:-/sbin/init}
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/init b/meta/recipes-core/initrdscripts/initramfs-framework/init
index a48b77e95e..5dd252219a 100755
--- a/meta/recipes-core/initrdscripts/initramfs-framework/init
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/init
@@ -81,9 +81,11 @@  EFI_DIR=/sys/firmware/efi  # place to store device firmware information
 touch /etc/fstab
 
 # initialize /proc, /sys, /run/lock and /var/lock
-mkdir -p /proc /sys /run/lock /var/lock
+mkdir -p /proc /sys /run /var/lock
 mount -t proc proc /proc
 mount -t sysfs sysfs /sys
+mount -t tmpfs tmpfs /run
+mkdir -p /run/lock
 
 if [ -d $EFI_DIR ];then
 	mount -t efivarfs none /sys/firmware/efi/efivars