Fix image size to fit filesystem journal

Our logic to determine needed image size doesnt fully account for the
in-filesystem journal. This only shows up when creating images that are
very small relative to the FS journal size.

Change-Id: Ic3c2bcd31ec4fee6bcd9f67767842eb3fbe20d3a
This commit is contained in:
Gregory Haynes 2015-03-31 04:52:08 +00:00
parent e9ac9c9823
commit 361a7a60b9

View File

@ -207,15 +207,18 @@ else
# Rounding down size so that is is a multiple of 64, works around a bug in # Rounding down size so that is is a multiple of 64, works around a bug in
# qemu-img that may occur when compressing raw images that aren't a multiple # qemu-img that may occur when compressing raw images that aren't a multiple
# of 64k. https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1180021 # of 64k. https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1180021
_NEEDED_SIZE=$(sudo du --block-size=600 -x -s ${TMP_BUILD_DIR}/built | \ du_size=$(sudo du --block-size=600 -x -s ${TMP_BUILD_DIR}/built |\
awk ' { print $1 - ( $1 % 64) } ') awk ' { print $1 }')
truncate -s${_NEEDED_SIZE}K $TMP_IMAGE_PATH
if [ "$FS_TYPE" = "ext4" ] ; then if [ "$FS_TYPE" = "ext4" ] ; then
# Very conservative to handle images being resized a lot # Very conservative to handle images being resized a lot
# Without -J option specified, default journal size will be set to 32M # We set journal size to 64M so our journal is large enough when we
# and online resize will be failed with error of needs too many credits. # perform an FS resize.
MKFS_OPTS="-i 4096 -J size=64 $MKFS_OPTS" MKFS_OPTS="-i 4096 -J size=64 $MKFS_OPTS"
du_size=$(( $du_size + 65536 ))
fi fi
_NEEDED_SIZE=$(echo "$du_size" | awk ' { print $1 + 64 - ( $1 % 64) } ')
truncate -s${_NEEDED_SIZE}K $TMP_IMAGE_PATH
fi fi
if [ -n "$MAX_ONLINE_RESIZE" ]; then if [ -n "$MAX_ONLINE_RESIZE" ]; then