From 596520acd93931ef86c0fc34dd3ec0e234885836 Mon Sep 17 00:00:00 2001 From: David James Date: Mon, 15 Aug 2011 17:11:00 -0700 Subject: [PATCH] Resize image without using a loop device to avoid sync. To resize an image, there's no need to use a loop device. We can just operate on the image directly. This is simpler and avoids doing a sync which can noticeably delay the build. BUG=chromium-os:19150 TEST=Run image_to_vm.sh --board=x86-mario Change-Id: Idbfc99cee9fd890aaad6379fbde511b273cc1d41 Reviewed-on: http://gerrit.chromium.org/gerrit/6036 Reviewed-by: Anush Elangovan Reviewed-by: Chris Sosa Tested-by: David James --- image_to_vm.sh | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/image_to_vm.sh b/image_to_vm.sh index 558c4ba71f..ed360a15f0 100755 --- a/image_to_vm.sh +++ b/image_to_vm.sh @@ -157,17 +157,8 @@ else echo "Resizing stateful partition to ${FLAGS_statefulfs_size}MB" # Extend the original file size to the new size. - dd if=/dev/zero of="${TEMP_STATE}" bs=1 count=1 \ - seek=$((STATEFUL_SIZE_BYTES - 1)) - # Resize the partition. - STATEFUL_LOOP_DEV=$(sudo losetup --show -f "${TEMP_STATE}") - if [ -z "${STATEFUL_LOOP_DEV}" ]; then - die "No free loop device. Free up a loop device or reboot. Exiting." - fi - sudo e2fsck -pf "${STATEFUL_LOOP_DEV}" - sudo resize2fs "${STATEFUL_LOOP_DEV}" - sudo sync - sudo losetup -d "${STATEFUL_LOOP_DEV}" + sudo e2fsck -pf "${TEMP_STATE}" + sudo resize2fs "${TEMP_STATE}" ${FLAGS_statefulfs_size}M fi fi TEMP_PMBR="${TEMP_DIR}"/pmbr