From 212d71d273023470b82854c363854b301bd11314 Mon Sep 17 00:00:00 2001 From: Yevgeny Popovych Date: Fri, 20 Jul 2018 18:14:20 +0300 Subject: ostree-initrd: Make it an initramfs, not initrd The reasoning here is to allow initramfs generated by this recipe to be included in FIT. To do so w/o changing openembedded-core (it allows only cpio format) - init script should be able to execute from a rootfs (i.e. true initramfs), not ramdisk (initrd). See [1] for more information on these keywords. The gist of this change is switch from `pivot_root` to `switch_root`. This also allows to get rid of some clutter, since `switch_root` handles transition to new sysroot all by itself. Again, see [1] for details on these utility/syscall. [1] https://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt Signed-off-by: Yevgeny Popovych --- recipes-sota/ostree-initrd/files/init.sh | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'recipes-sota/ostree-initrd/files/init.sh') diff --git a/recipes-sota/ostree-initrd/files/init.sh b/recipes-sota/ostree-initrd/files/init.sh index d7e0429..4818a07 100644 --- a/recipes-sota/ostree-initrd/files/init.sh +++ b/recipes-sota/ostree-initrd/files/init.sh @@ -41,7 +41,6 @@ do_mount_fs sysfs /sys do_mount_fs devtmpfs /dev do_mount_fs devpts /dev/pts do_mount_fs tmpfs /dev/shm -do_mount_fs tmpfs /tmp do_mount_fs tmpfs /run # check if smack is active (and if so, mount smackfs) @@ -63,23 +62,10 @@ mount "$ostree_sysroot" /sysroot || { sleep 5 mount "$ostree_sysroot" /sysroot || bail_out "Unable to mount $ostree_sysroot as physical sysroot" } -ostree-prepare-root /sysroot - -# move mounted devices to new root -cd /sysroot -for x in dev proc run; do - log_info "Moving /$x to new rootfs" - mount -o move "/$x" "$x" -done - -# switch to new rootfs -log_info "Switching to new rootfs" -mkdir -p run/initramfs -pivot_root . run/initramfs || bail_out "pivot_root failed." - -log_info "Launching target init" +ostree-prepare-root /sysroot -exec chroot . sh -c 'umount /run/initramfs; exec /sbin/init' \ - dev/console 2>&1 +log_info "Switching to rootfs" +exec switch_root /sysroot /sbin/init +bail_out "Failed to switch_root to $ostree_sysroot" -- cgit v1.2.3-54-g00ecf