public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH] Unmount filesystems automounted by udev except the one with the rootfs
@ 2013-02-15 21:04 Konrad Scherer
  0 siblings, 0 replies; only message in thread
From: Konrad Scherer @ 2013-02-15 21:04 UTC (permalink / raw)
  To: openembedded-core

From: Konrad Scherer <Konrad.Scherer@windriver.com>

Unmount all filesystems automounted by udev except one with
rootfs since the filesystem will be destroyed by switch_root.

Signed-off-by: Konrad Scherer <Konrad.Scherer@windriver.com>
---
 meta/recipes-core/initrdscripts/files/init-live.sh |   21 ++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/meta/recipes-core/initrdscripts/files/init-live.sh b/meta/recipes-core/initrdscripts/files/init-live.sh
index 4f8618b..21939ad 100644
--- a/meta/recipes-core/initrdscripts/files/init-live.sh
+++ b/meta/recipes-core/initrdscripts/files/init-live.sh
@@ -75,6 +75,8 @@ read_args() {
 }
 
 boot_live_root() {
+    local rootfs_dev=$1
+
     killall udevd 2>/dev/null
 
     # Move the mount points of some filesystems over to
@@ -82,8 +84,19 @@ boot_live_root() {
     mount -n --move /proc ${ROOT_MOUNT}/proc
     mount -n --move /sys ${ROOT_MOUNT}/sys
     mount -n --move /dev ${ROOT_MOUNT}/dev
-    # Move /media/$i over to the real root filesystem
-    mount -n --move /media/$i ${ROOT_MOUNT}/media/realroot
+
+    # umount all filesystems automounted by udev except one with
+    # rootfs since the filesystem will be destroyed by switch_root
+    # They cannot be moved, because the read only rootfs may not have
+    # the corresponding mount points
+    for dir in `ls /media 2>/dev/null`; do
+        if [ "x${dir}" != "x${rootfs_dev}" ]; then
+            umount /media/${dir}
+        else
+            # Move iso mount with rootfs over to the real root filesystem
+            mount -n --move /media/${rootfs_dev} ${ROOT_MOUNT}/media/realroot
+        fi
+    done
 
     cd $ROOT_MOUNT
     exec switch_root -c /dev/console $ROOT_MOUNT /sbin/init
@@ -149,13 +162,13 @@ case $label in
 		mkdir /cow
 		mount -t tmpfs -o rw,noatime,mode=755 tmpfs /cow
 		mount -t unionfs -o dirs=/cow:/rootfs-tmp=ro unionfs $ROOT_MOUNT
-		boot_live_root
+		boot_live_root $i
 	    fi
 	else
 	    if ! $MOUNT -o rw,loop,noatime,nodiratime /media/$i/$ISOLINUX/$ROOT_IMAGE $ROOT_MOUNT ; then
 		fatal "Could not mount rootfs image"
 	    else
-		boot_live_root
+		boot_live_root $i
 	    fi
 	fi
 	;;
-- 
1.7.10.4




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-02-16  0:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-15 21:04 [PATCH] Unmount filesystems automounted by udev except the one with the rootfs Konrad Scherer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox