From be817e0bd137009ee158eafe16bc292421e105bb Mon Sep 17 00:00:00 2001 From: Pat Viafore Date: Thu, 6 Jun 2019 08:15:40 -0500 Subject: [PATCH] Unmount the image before we convert to qcow2 to avoid corruption --- live-build/ubuntu-cpc/hooks.d/base/kvm-image.binary | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/live-build/ubuntu-cpc/hooks.d/base/kvm-image.binary b/live-build/ubuntu-cpc/hooks.d/base/kvm-image.binary index cb98a2b1..1598390d 100644 --- a/live-build/ubuntu-cpc/hooks.d/base/kvm-image.binary +++ b/live-build/ubuntu-cpc/hooks.d/base/kvm-image.binary @@ -32,6 +32,9 @@ create_derivative "disk" "kvm" #sets ${derivative_img} mount_disk_image ${derivative_img} ${mount_d} # unmount disk image and remove created folders on exit +# even though we unmount manually before we convert to +# qcow2, we have this here just in case we error out before +# that step cleanup_kvm() { if [ -d "$mount_d" ]; then umount_disk_image "$mount_d" @@ -61,4 +64,10 @@ env DEBIAN_FRONTEND=noninteractive chroot "${mount_d}" apt-get \ clean create_manifest ${mount_d} livecd.ubuntu-cpc.disk-kvm.manifest + +# unmount disk image to prevent corruption +# and remove it so the trap doesn't try to unmount it again +umount_disk_image ${mount_d} +rm -rf ${mount_d} + convert_to_qcow2 ${derivative_img} livecd.ubuntu-cpc.disk-kvm.img \ No newline at end of file