Add a parameter to set free space in qemu images

Avoid the need to redimension the qemu disk size.
This commit is contained in:
Jacen 2018-03-19 19:18:58 +01:00
parent b5699a9a4a
commit 4790ecd526
5 changed files with 13 additions and 3 deletions

View File

@ -97,6 +97,9 @@ The following environment variables are supported:
Change the keyboard default mapping (gb=qwerty, fr=azerty).
* `FREE_SPACE_MB` (Default: <int> 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:

View File

@ -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"}

View File

@ -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"

View File

@ -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}" <<EOF
o

View File

@ -17,7 +17,7 @@ BOOT_SIZE="$(( BOOT_SIZE / 1000000 + 1))"
ROOT_SIZE="$(( ROOT_SIZE / 1000000 + 1))"
BOOT_NOM="$(( BOOT_SIZE * 3 ))"
ROOT_NOM="$(( ROOT_SIZE + 400 ))"
ROOT_NOM="$(( ROOT_SIZE + 400))"
mv "${NOOBS_DIR}/OS.png" "${NOOBS_DIR}/${NOOBS_NAME// /_}.png"