Fix diskimage-builder image size
This patch fixes the calculation of the resultant image size when building an image with diskimage-builder on ext4 a filesystem. Prior to this, using the '--image-size 2' (2GB) setting would generate an image that would not boot under a 2GB nova flavor. Change-Id: I7a753bdef84c6300ccea73ae4a92bf330dcd77cb Closes-Bug: #1513622
This commit is contained in:
parent
6f3185f251
commit
590dce8dcc
@ -241,9 +241,6 @@ if [ -n "$DIB_IMAGE_SIZE" ]; then
|
||||
du_size=$(echo "$DIB_IMAGE_SIZE" | awk '{printf("%d\n",$1 * 1024 *1024)}')
|
||||
else
|
||||
# in kb*0.60 - underreport to get a slightly bigger device
|
||||
# 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
|
||||
du_size=$(sudo du --block-size=600 -x -s ${TMP_BUILD_DIR}/built |\
|
||||
awk ' { print $1 }')
|
||||
fi
|
||||
@ -252,11 +249,18 @@ if [ "$FS_TYPE" = "ext4" ] ; then
|
||||
# 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 ))
|
||||
# Grow the image size to account for the journal, only if the user
|
||||
# has not asked for a specific size.
|
||||
if [ -z "$DIB_IMAGE_SIZE" ]; then
|
||||
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
|
||||
# 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
|
||||
du_size=$(echo "$du_size" | awk ' { if ($1 % 64 != 0) print $1 + 64 - ( $1 % 64); else print $1; } ')
|
||||
truncate -s${du_size}K $TMP_IMAGE_PATH
|
||||
|
||||
if [ -n "$MAX_ONLINE_RESIZE" ]; then
|
||||
MKFS_OPTS="-E resize=$MAX_ONLINE_RESIZE $MKFS_OPTS"
|
||||
|
Loading…
Reference in New Issue
Block a user