Merge "Support defining the free space in the image"

This commit is contained in:
Zuul 2019-05-07 10:14:01 +00:00 committed by Gerrit Code Review
commit fa34eb7fe4
3 changed files with 21 additions and 3 deletions

View File

@ -62,6 +62,7 @@ function show_options () {
echo " --logfile -- save run output to given logfile (implies DIB_QUIET=1)"
echo " --checksum -- generate MD5 and SHA256 checksum files for the created image"
echo " --image-size size -- image size in GB for the created image"
echo " --image-extra-size size -- extra image size in GB for the created image"
echo " --image-cache directory -- location for cached images(default ~/.cache/image-create)"
echo " --max-online-resize size -- max number of filesystem blocks to support when resizing."
echo " Useful if you want a really large root partition when the image is deployed."
@ -148,6 +149,7 @@ while true ; do
-p) IFS="," read -a _INSTALL_PACKAGES <<< "$2"; export INSTALL_PACKAGES=( ${INSTALL_PACKAGES[@]} ${_INSTALL_PACKAGES[@]} ) ; shift 2 ;;
--checksum) shift; export DIB_CHECKSUM=1;;
--image-size) export DIB_IMAGE_SIZE=$2; shift 2;;
--image-extra-size) export DIB_IMAGE_EXTRA_SIZE=$2; shift 2;;
--image-cache) export DIB_IMAGE_CACHE=$2; shift 2;;
--max-online-resize) export MAX_ONLINE_RESIZE=$2; shift 2;;
--mkfs-journal-size) export DIB_JOURNAL_SIZE=$2; shift 2;;
@ -378,8 +380,15 @@ else
echo "Calculating image size (this may take a minute)..."
sudo du -a -c -x ${TMP_BUILD_DIR}/built > ${du_output}
# the last line is the total size from "-c".
if [ -n "$DIB_IMAGE_EXTRA_SIZE" ]; then
# add DIB_IMAGE_EXTRA_SIZE to create a bigger image as requested
du_extra_size=$(echo "$DIB_IMAGE_EXTRA_SIZE" | awk '{printf("%d\n",$1 * 1024 *1024)}')
du_size_tmp=$(tail -n1 ${du_output} | cut -f1)
du_size=$(echo "$du_size_tmp $du_extra_size" | awk '{print int($1 + $2)}')
else
# scale this by 0.6 to create a slightly bigger image
du_size=$(tail -n1 ${du_output} | cut -f1 | awk '{print int($1 / 0.6)}')
fi
$xtrace
fi

View File

@ -617,7 +617,7 @@ more complicated block-device layouts with multiple partitions, you
may need to take into account the special behaviour described below.
The ``local_loop`` module will take it's default size from the
following argument.
following arguments:
``--image-size``
The size of loopback device which the image will be generated in,
@ -625,6 +625,11 @@ following argument.
from the on-disk size of the image and then scaled up by a fixed
60% factor. Can also set ``DIB_IMAGE_SIZE``.
``--image-extra-size``
Extra space to add when automatically calculating image size, in
gigabytes. This overrides the default 60% scale up as described
above for ``--image-size``. Can also set ``DIB_IMAGE_EXTRA_SIZE``.
The special node named ``mkfs_root`` is affected by the following;
this reflects that the standard layout has only a single root
partition so the options are, in effect, global for the default

View File

@ -0,0 +1,4 @@
---
features:
- The ``--image-extra-size`` option is provided to override the default
60% padding growth of the image size with a fixed gigabyte value.