From 4790ecd5263677b0cded00b90697cfa2aae602ba Mon Sep 17 00:00:00 2001 From: Jacen Date: Mon, 19 Mar 2018 19:18:58 +0100 Subject: [PATCH] Add a parameter to set free space in qemu images Avoid the need to redimension the qemu disk size. --- README.md | 7 +++++-- build.sh | 1 + config.exemple | 1 + export-image/prerun.sh | 5 +++++ export-noobs/00-release/00-run.sh | 2 +- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5dd22b8..fea5552 100755 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ The following environment variables are supported: be built and cached. Note, `WORK_DIR` stores a complete copy of the target system for each build stage, amounting to tens of gigabytes in the case of Raspbian. - + **CAUTION**: If your working directory is on an NTFS partition you probably won't be able to build. Make sure this is a proper Linux filesystem. * `DEPLOY_DIR` (Default: `"$BASE_DIR/deploy"`) @@ -97,6 +97,9 @@ The following environment variables are supported: Change the keyboard default mapping (gb=qwerty, fr=azerty). + * `FREE_SPACE_MB` (Default: 400) + + Add a free space in the partition (value in megabyte). If Qemu image is generated it could be usefull to have a lot of free space. A simple example for building Raspbian: @@ -297,4 +300,4 @@ To resolve this, ensure that the following files are available (install them if /usr/bin/qemu-arm-static ``` -You may also need to load the module by hand - run `modprobe binfmt_misc`. +You may also need to load the module by hand - run `modprobe binfmt_misc`. \ No newline at end of file diff --git a/build.sh b/build.sh index 809d27a..a79d9ba 100755 --- a/build.sh +++ b/build.sh @@ -134,6 +134,7 @@ fi export USE_QEMU="${USE_QEMU:-0}" export LAST_STAGE=${LAST_STAGE:-5} +export FREE_SPACE_MB=${FREE_SPACE_MB:-400} export RPI_LOCALHOST=${RPI_LOCALHOST:-"raspberrypi"} export RPI_USERNAME=${RPI_USERNAME:-"pi"} export RPI_USERPASS=${RPI_USERPASS:-"raspberry"} diff --git a/config.exemple b/config.exemple index d82e284..fb3b0ae 100644 --- a/config.exemple +++ b/config.exemple @@ -1,6 +1,7 @@ IMG_NAME="Raspbian" USE_QEMU=1 LAST_STAGE=5 +FREE_SPACE_MB=500 KEYBOARD_LANG="gb" RPI_LOCALHOST="raspberrypi" RPI_USERNAME="pi" diff --git a/export-image/prerun.sh b/export-image/prerun.sh index 0ac7181..26a411e 100755 --- a/export-image/prerun.sh +++ b/export-image/prerun.sh @@ -16,6 +16,11 @@ ROUND_SIZE="$((4 * 1024 * 1024))" ROUNDED_ROOT_SECTOR=$(((2 * BOOT_SIZE + ROUND_SIZE) / ROUND_SIZE * ROUND_SIZE / 512 + 8192)) IMG_SIZE=$(((BOOT_SIZE + TOTAL_SIZE + (800 * 1024 * 1024) + ROUND_SIZE - 1) / ROUND_SIZE * ROUND_SIZE)) +if [ "${USE_QEMU}" = "1" ]; then + log "Added ${FREE_SPACE_MB} to qemu image (${IMG_SIZE})" + IMG_SIZE=$(((BOOT_SIZE + TOTAL_SIZE + (FREE_SPACE_MB * 1024 * 1024) + ROUND_SIZE - 1) / ROUND_SIZE * ROUND_SIZE)) +fi + truncate -s "${IMG_SIZE}" "${IMG_FILE}" fdisk -H 255 -S 63 "${IMG_FILE}" <