mirror of
https://github.com/flatcar/scripts.git
synced 2026-05-04 19:56:32 +02:00
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 <anush@chromium.org> Reviewed-by: Chris Sosa <sosa@chromium.org> Tested-by: David James <davidjames@chromium.org>
This commit is contained in:
parent
63f62623d4
commit
596520acd9
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user