Run udevadm settle after kpartx -l
it may happen that if the system where disk-image-create runs is busy, then the kpartx -l run may leave a stale autodelete loop device. This is because kpartx -l first adds a new loop device, then does the listing and removes the loop device. The latter may not end before the end of the kpartx run, leaving a loop device marked as autodelete. Such kind of loop device will automatically delete itself, so the rm -r $WORKING after sudo umount -f $WORKING/mnt in the EXIT trap will fail because $WORKING does not exist anymore. To prevent this situation, just ask udev to finish its operations, properly removing the (temporary) loop device. Change-Id: I12246f3dbe6b5669e698767682a5a142f803823b
This commit is contained in:
parent
100959de8d
commit
626ca9ad47
@ -54,6 +54,7 @@ function extract_image() {
|
|||||||
qemu-img convert -f qcow2 -O raw $CACHED_IMAGE $WORKING/$RAW_FILE
|
qemu-img convert -f qcow2 -O raw $CACHED_IMAGE $WORKING/$RAW_FILE
|
||||||
|
|
||||||
ROOT_PARTITON=p$(sudo kpartx -l $WORKING/$RAW_FILE | awk "/loop[0-9]+p/"|wc -l)
|
ROOT_PARTITON=p$(sudo kpartx -l $WORKING/$RAW_FILE | awk "/loop[0-9]+p/"|wc -l)
|
||||||
|
sudo udevadm settle
|
||||||
|
|
||||||
# kpartx fails if no /dev/loop* exists, "losetup -f" prints first unused
|
# kpartx fails if no /dev/loop* exists, "losetup -f" prints first unused
|
||||||
# loop device and creates it if it doesn't exist
|
# loop device and creates it if it doesn't exist
|
||||||
|
Loading…
Reference in New Issue
Block a user