summaryrefslogtreecommitdiffstats
path: root/tools/daisy-img-modify.sh
diff options
context:
space:
mode:
authorAlex Yang <yangyang1@zte.com.cn>2017-03-08 00:30:24 +0800
committerAlex Yang <yangyang1@zte.com.cn>2017-03-09 23:14:11 +0800
commit208f8e2530de8689bde6178d203f9bbe68de8b5c (patch)
tree3ba1a40b6d3851e86801f5b08700a6a8f7157a5f /tools/daisy-img-modify.sh
parentad7a882c71c0ed779b2111f400ac6b8bd108e4c5 (diff)
Eliminate the exception in image-modify
Sometimes kpartx fails when it deletes the partition device mappings because of the automatic mounting to /run/media/root/xxxx. So umounting and removing forcibly are needed. Change-Id: Ic8a19ef9139adb9c0c5c4bead0ae0ffbd92f24b8 Signed-off-by: Alex Yang <yangyang1@zte.com.cn>
Diffstat (limited to 'tools/daisy-img-modify.sh')
-rwxr-xr-xtools/daisy-img-modify.sh14
1 files changed, 12 insertions, 2 deletions
diff --git a/tools/daisy-img-modify.sh b/tools/daisy-img-modify.sh
index 60b60d26..8e025168 100755
--- a/tools/daisy-img-modify.sh
+++ b/tools/daisy-img-modify.sh
@@ -135,6 +135,16 @@ install_utils()
fi
}
+# Eliminate exceptions
+eliminate()
+{
+ if [ -b /dev/mapper/$loopdevice ]; then
+ umount /dev/mapper/$loopdevice || true
+ dmsetup remove $loopdevice || true
+ fi
+ return 0
+}
+
# resize image
resize() {
install_utils
@@ -149,7 +159,7 @@ resize() {
fdisk -l /dev/${loopdevice:0:5} || true
growpart /dev/${loopdevice:0:5} 1
dmsetup clear $loopdevice
- kpartx -dv $raw_imgfile
+ kpartx -dv $raw_imgfile || eliminate
}
# mount image
@@ -193,7 +203,7 @@ cleanup() {
mount | grep $mountdir/proc && umount $mountdir/proc
mount | grep $mountdir && umount $mountdir
if [ -f $raw_imgfile ]; then
- kpartx -dv $raw_imgfile || true
+ kpartx -dv $raw_imgfile || eliminate
fi
rm -f $raw_imgfile
rm -rf $mountdir