diff options
author | Yevgeny Popovych <yevgenyp@pointgrab.com> | 2018-07-20 18:14:20 +0300 |
---|---|---|
committer | Phil Wise <philip.wise@here.com> | 2018-08-14 16:03:10 +0200 |
commit | 212d71d273023470b82854c363854b301bd11314 (patch) | |
tree | 7f2fdf96c359f8a39e440624103cd1c5309e3917 /recipes-sota/ostree-initrd/files/init.sh | |
parent | 625c3a3a7b7390012c26b34ce4bb4cd277d9ed07 (diff) | |
download | meta-updater-212d71d273023470b82854c363854b301bd11314.tar.gz |
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 <yevgenyp@pointgrab.com>
Diffstat (limited to 'recipes-sota/ostree-initrd/files/init.sh')
-rw-r--r-- | recipes-sota/ostree-initrd/files/init.sh | 22 |
1 files changed, 4 insertions, 18 deletions
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 | |||
41 | do_mount_fs devtmpfs /dev | 41 | do_mount_fs devtmpfs /dev |
42 | do_mount_fs devpts /dev/pts | 42 | do_mount_fs devpts /dev/pts |
43 | do_mount_fs tmpfs /dev/shm | 43 | do_mount_fs tmpfs /dev/shm |
44 | do_mount_fs tmpfs /tmp | ||
45 | do_mount_fs tmpfs /run | 44 | do_mount_fs tmpfs /run |
46 | 45 | ||
47 | # check if smack is active (and if so, mount smackfs) | 46 | # check if smack is active (and if so, mount smackfs) |
@@ -63,23 +62,10 @@ mount "$ostree_sysroot" /sysroot || { | |||
63 | sleep 5 | 62 | sleep 5 |
64 | mount "$ostree_sysroot" /sysroot || bail_out "Unable to mount $ostree_sysroot as physical sysroot" | 63 | mount "$ostree_sysroot" /sysroot || bail_out "Unable to mount $ostree_sysroot as physical sysroot" |
65 | } | 64 | } |
66 | ostree-prepare-root /sysroot | ||
67 | |||
68 | # move mounted devices to new root | ||
69 | cd /sysroot | ||
70 | for x in dev proc run; do | ||
71 | log_info "Moving /$x to new rootfs" | ||
72 | mount -o move "/$x" "$x" | ||
73 | done | ||
74 | |||
75 | # switch to new rootfs | ||
76 | log_info "Switching to new rootfs" | ||
77 | mkdir -p run/initramfs | ||
78 | 65 | ||
79 | pivot_root . run/initramfs || bail_out "pivot_root failed." | 66 | ostree-prepare-root /sysroot |
80 | |||
81 | log_info "Launching target init" | ||
82 | 67 | ||
83 | exec chroot . sh -c 'umount /run/initramfs; exec /sbin/init' \ | 68 | log_info "Switching to rootfs" |
84 | <dev/console >dev/console 2>&1 | 69 | exec switch_root /sysroot /sbin/init |
85 | 70 | ||
71 | bail_out "Failed to switch_root to $ostree_sysroot" | ||