From 063e2617d6c9c5671774ff5a86329f713ed673f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 30 Mar 2015 16:18:52 +0200 Subject: [PATCH] Cleanup after failed volatile.img preparation --- linux/aux-tools/prepare-volatile-img.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/linux/aux-tools/prepare-volatile-img.sh b/linux/aux-tools/prepare-volatile-img.sh index 41406a05..28a8207f 100755 --- a/linux/aux-tools/prepare-volatile-img.sh +++ b/linux/aux-tools/prepare-volatile-img.sh @@ -20,6 +20,15 @@ if [ -e "$FILENAME" ]; then exit 1 fi +# Cleanup lefovers from possible previous run +loopdev=`losetup -a | grep "$FILENAME" | cut -f 1 -d :` +if [ -n "$loopdev" ]; then + dmsetup remove `basename $loopdev`p1 2>/dev/null + dmsetup remove `basename $loopdev`p2 2>/dev/null + losetup -d $loopdev + udevadm settle +fi + TOTAL_SIZE=$[ $ROOT_SIZE + $SWAP_SIZE + 512 ] truncate -s ${TOTAL_SIZE}M "$FILENAME" sfdisk --no-reread -u M "$FILENAME" > /dev/null 2> /dev/null <