[3/4] initramfs-module-setup-live: add umountfs

Submitted by Hongxu Jia on Dec. 3, 2018, 10:13 a.m. | Patch ID: 156818

Details

Message ID 1543832010-8787-3-git-send-email-hongxu.jia@windriver.com
State New
Headers show

Commit Message

Hongxu Jia Dec. 3, 2018, 10:13 a.m.
In init-live.sh, due to udev, mount points (/run\/media/**) are available,
except realroot, other mount points are moved to the corresponding directories
under the real root filesystem.

For initramfs-module-setup-live, rather than move them to real root,
just umount these mount points. After switch_root, let udev/fstab in
rootfs to process the partition. It aligns the principle that `Initrd
is used to mount the root file system at boot time'[1]
[1] https://en.wikipedia.org/wiki/Initial_ramdisk

Umount dev rather mount point to avoid `spaces in the mount points to
actual ASCII char'

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 meta/recipes-core/initrdscripts/initramfs-framework/umountfs   | 10 ++++++++++
 .../initrdscripts/initramfs-module-setup-live_1.0.bb           |  3 +++
 2 files changed, 13 insertions(+)
 create mode 100644 meta/recipes-core/initrdscripts/initramfs-framework/umountfs

Patch hide | download patch | download mbox

diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/umountfs b/meta/recipes-core/initrdscripts/initramfs-framework/umountfs
new file mode 100644
index 0000000..9d41538
--- /dev/null
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/umountfs
@@ -0,0 +1,10 @@ 
+umountfs_enabled() {
+    return 0
+}
+
+umountfs_run() {
+    # Umount available mount points
+    for dev in `awk '/\/dev.* \/run\/media/{print $1}' /proc/mounts`; do
+        umount $dev
+    done
+}
diff --git a/meta/recipes-core/initrdscripts/initramfs-module-setup-live_1.0.bb b/meta/recipes-core/initrdscripts/initramfs-module-setup-live_1.0.bb
index c0ebd40..c8986cb 100644
--- a/meta/recipes-core/initrdscripts/initramfs-module-setup-live_1.0.bb
+++ b/meta/recipes-core/initrdscripts/initramfs-module-setup-live_1.0.bb
@@ -11,6 +11,7 @@  FILESEXTRAPATHS_prepend := "${THISDIR}/initramfs-framework:"
 SRC_URI = "file://setup-live \
            file://union-fs \
            file://realroot \
+           file://umountfs \
 "
 
 S = "${WORKDIR}"
@@ -20,9 +21,11 @@  do_install() {
     install -m 0755 ${WORKDIR}/setup-live ${D}/init.d/80-setup-live
     install -m 0755 ${WORKDIR}/union-fs ${D}/init.d/91-union-fs
     install -m 0755 ${WORKDIR}/realroot ${D}/init.d/92-realroot
+    install -m 0755 ${WORKDIR}/umountfs ${D}/init.d/93-umountfs
 }
 
 FILES_${PN} = "/init.d/80-setup-live \
                /init.d/91-union-fs \
                /init.d/92-realroot \
+               /init.d/93-umountfs \
               "