Merge "Fix image size to fit filesystem journal"

This commit is contained in:
Jenkins 2015-04-21 05:05:31 +00:00 committed by Gerrit Code Review
commit 7c4c504334

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