From 1dea2f35249bdb1aed50ef6a580d52da754396e6 Mon Sep 17 00:00:00 2001 From: Chris Alfonso Date: Thu, 15 Aug 2013 12:45:31 -0400 Subject: [PATCH] Call sync before unmounting keeps the mount from being busy. here is a bug associated with this patch because there is a workaround included. Calling sync to enable the unmounting... https://bugs.launchpad.net/diskimage-builder/+bug/1214388 Change-Id: I9d5a1f092fd8f3ae1c14de03dd516203baab4da3 --- lib/img-functions | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/img-functions b/lib/img-functions index 470f8ed6..23a19d19 100644 --- a/lib/img-functions +++ b/lib/img-functions @@ -14,6 +14,12 @@ # under the License. function unmount_image () { + # Calling sync before helps ensure the mount isn't busy when you unmount it. + # Previously observing having disk corruption issues; one possibility is + # qemu-nbd not flushing dirty pages on disconnect? + # https://bugs.launchpad.net/diskimage-builder/+bug/1214388 + sync + # unmount from the chroot # Don't use TMP_MOUNT_PATH here, it might not have been set. local MOUNTS @@ -21,12 +27,6 @@ function unmount_image () { for M in $MOUNTS; do sudo umount -f $M || true done - # give it a second (ok really 5) to umount XXX - why? should instead track - # the mount data / lsof etc. - sleep 5 - # having disk corruption issues; one possibility is qemu-nbd not flushing - # dirty pages on disconnect? - sync if [ -n "$EXTRA_UNMOUNT" ]; then $EXTRA_UNMOUNT fi