From d76bd0ad1d61aca444c8e09c59a446a58dd17c3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 3 Apr 2015 11:24:37 +0200 Subject: [PATCH] Use partitioned loop device instead of device-mapper to prepare volatile.img There was a lot problems with device-mapper, at least it asynchronous creation, races with udev, problems with cleanup. --- linux/aux-tools/prepare-volatile-img.sh | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/linux/aux-tools/prepare-volatile-img.sh b/linux/aux-tools/prepare-volatile-img.sh index 60fb2ce3..3b293eca 100755 --- a/linux/aux-tools/prepare-volatile-img.sh +++ b/linux/aux-tools/prepare-volatile-img.sh @@ -20,15 +20,6 @@ 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 < /dev/null 2> /dev/null < /dev/null +loopdev=`losetup -f --show --partscan "$FILENAME"` +mkswap -f ${loopdev}p1 > /dev/null udevadm settle -kpartx -s -d ${loopdev} losetup -d ${loopdev} || : chown --reference `dirname "$FILENAME"` "$FILENAME"