initfs: Use a new tmpfs mount for run/initramfs
Keep /run/initramfs in shutdown but remove it at the beginning of init
Make /run/initramfs its own tmpfs so that switch_root doesn't nuke it
Refactor the root componet mountpoint name using the new variable api
Since systemd v254 now keeps the sys run proc dev mount trees under
/run/initramfs/ and doesn't force unmount ro and rw, we can switch
run/initramfs to a new tmpfs instead of a bind mount within run.
Repeated invocation of exec /init from /shutdown sh had been broken
since we started using switch_root because it removes all file content
in the same instance, including the run/initramfs/shutdown and friends
when starting the second boot because the former run/initramfs is part
of run and hence the new run/initrammfs. This was purging our
INITRD_INTERFACE shutdown hook.
Signed-off-by: Milton Miller <miltonm@us.ibm.com>
diff --git a/meta-phosphor/recipes-phosphor/initrdscripts/files/obmc-init.sh b/meta-phosphor/recipes-phosphor/initrdscripts/files/obmc-init.sh
index 389dcbc..536a40d 100644
--- a/meta-phosphor/recipes-phosphor/initrdscripts/files/obmc-init.sh
+++ b/meta-phosphor/recipes-phosphor/initrdscripts/files/obmc-init.sh
@@ -1,8 +1,9 @@
#!/bin/sh
fslist="proc sys dev run"
-rodir=run/initramfs/ro
-rwdir=run/initramfs/rw
+api=run/initramfs
+rodir=$api/ro
+rwdir=$api/rw
upper=$rwdir/cow
work=$rwdir/work
@@ -12,15 +13,21 @@
mount dev dev -tdevtmpfs
mount sys sys -tsysfs
mount proc proc -tproc
+if grep $api proc/mounts
+then
+ umount $api
+fi
if ! grep run proc/mounts
then
mount tmpfs run -t tmpfs -o mode=755,nodev
fi
+mkdir -p $api
+mount initrd $api -t tmpfs
+cp -rp init shutdown update whitelist bin sbin usr lib etc var $api
+
mkdir -p $rodir $rwdir
-mount --bind run/initramfs /run/initramfs
-cp -rp init shutdown update whitelist bin sbin usr lib etc var run/initramfs
# To start a interactive shell with job control at this point, run
# getty 38400 ttyS4