]> code.ossystems Code Review - openembedded-core.git/commitdiff
mkefidisk: Unmount after partitioning
authorDarren Hart <dvhart@linux.intel.com>
Thu, 25 Apr 2013 21:27:29 +0000 (14:27 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 2 May 2013 16:41:23 +0000 (17:41 +0100)
Some automounters are rather overzealous and like to mount things
immediately after partitioning. This can happen if the disk is being
reused and the partitions align exactly with the existing partitions
which have already been formatted. Move the unmount code into a function
and call it before and after partitioning.

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
scripts/contrib/mkefidisk.sh

index 741c3ab967937685e44393d99bef49b89b57a792..0c15104bb3e306d5fc6cfc6a8b6a3855942878ca 100755 (executable)
@@ -71,6 +71,20 @@ function device_details() {
        echo ""
 }
 
+function unmount_device() {
+       grep -q $DEVICE /proc/mounts
+       if [ $? -eq 0 ]; then
+               echo -n "$DEVICE listed in /proc/mounts, attempting to unmount..."
+               umount $DEVICE* 2>/dev/null
+               grep -q $DEVICE /proc/mounts
+               if [ $? -eq 0 ]; then
+                       echo "FAILED"
+                       exit 1
+               fi
+               echo "OK"
+       fi
+}
+
 
 #
 # Parse and validate arguments
@@ -100,17 +114,7 @@ fi
 #
 # Check if any $DEVICE partitions are mounted
 #
-grep -q $DEVICE /proc/mounts
-if [ $? -eq 0 ]; then
-       echo -n "$DEVICE listed in /proc/mounts, attempting to unmount..."
-       umount $DEVICE* 2>/dev/null
-       grep -q $DEVICE /proc/mounts
-       if [ $? -eq 0 ]; then
-               echo "FAILED"
-               exit 1
-       fi
-       echo "OK"
-fi
+unmount_device
 
 
 #
@@ -182,6 +186,12 @@ parted $DEVICE mkpart primary $SWAP_START 100%
 parted $DEVICE print
 
 
+#
+# Check if any $DEVICE partitions are mounted after partitioning
+#
+unmount_device
+
+
 #
 # Format $DEVICE partitions
 #