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
1 changed files with 8 additions and 5 deletions

View File

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