From 9926ee287976bd9ea8dfa233cba6fa88ec1058ca Mon Sep 17 00:00:00 2001 From: Will Drewry Date: Wed, 21 Jul 2010 15:11:10 -0500 Subject: [PATCH] build_image: avoid losetup -c because older kernels seem to balk Instead of resizing the loop device after adding padding for the hash tree data. Just ensure that the mkfs.ext3 call doesn't exceed the rootfs size. TEST=reran build_image on my lucid machine and checked the rootfs size; asked someone with hardy machine to test. BUG=none Change-Id: I59f95e1d17e35aca265bd44bb863da6069c05bd2 Review URL: http://codereview.chromium.org/3048009 --- build_image | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/build_image b/build_image index 0f8324bd00..c1505c76d2 100755 --- a/build_image +++ b/build_image @@ -532,18 +532,15 @@ create_base_image() { ROOT_SIZE_BYTES=$((1024 * 1024 * ${FLAGS_rootfs_size})) fi - dd if=/dev/zero of="${ROOT_FS_IMG}" bs=1 count=1 seek=$((ROOT_SIZE_BYTES - 1)) - sudo losetup "${LOOP_DEV}" "${ROOT_FS_IMG}" - sudo mkfs.ext3 "${LOOP_DEV}" - - # Pad out 10% for the hash tree. This currently _exact_ for - # default configuration. More space may be needed for different options. + # Pad out for the hash tree. ROOT_HASH_PAD=$((FLAGS_rootfs_hash_pad * 1024 * 1024)) info "Padding the rootfs image by ${ROOT_HASH_PAD} bytes for hash data" + dd if=/dev/zero of="${ROOT_FS_IMG}" bs=1 count=1 \ seek=$((ROOT_SIZE_BYTES + ROOT_HASH_PAD - 1)) - # Update to reflect the new capacity in the loop device. - sudo losetup -c "${LOOP_DEV}" + sudo losetup "${LOOP_DEV}" "${ROOT_FS_IMG}" + # Specify a block size and block count to avoid using the hash pad. + sudo mkfs.ext3 -b 4096 "${LOOP_DEV}" "$((ROOT_SIZE_BYTES / 4096))" # Tune and mount rootfs. # TODO(wad) rename the disk label to match the GPT since we