Grow cloud image root by 4 GB before customizing (Docker install filled the disk)

This commit is contained in:
steffen committed 2026-11-04 21:05:28 +01:00
1 parent 5a564aaa47
commit 665eadc8d6
2 files changed
+10 -1

No files matched your search

+5 -1
View File
@@ -267,10 +267,14 @@ print_summary() {
build_template() { build_template() {
local id=$1 name=$2 cores=$3 ram=$4 disk=$5 docker=$6 local id=$1 name=$2 cores=$3 ram=$4 disk=$5 docker=$6
local image="$WORKDIR/build-$id.img" local image="$WORKDIR/build-$id.img"
local -a customize=(--install qemu-guest-agent) # The cloud image's root filesystem is only ~2 GB, too small for Docker.
# Grow the image by 4 GB and the root partition with it before installing.
local -a customize=(--run-command 'growpart /dev/sda 1 && resize2fs /dev/sda1'
--install qemu-guest-agent)
info "[$id] Preparing image for $name" info "[$id] Preparing image for $name"
cp "$BASE_IMAGE" "$image" cp "$BASE_IMAGE" "$image"
qemu-img resize -q "$image" +4G
if [[ $docker == y ]]; then if [[ $docker == y ]]; then
customize+=(--run-command 'curl -fsSL https://get.docker.com | sh') customize+=(--run-command 'curl -fsSL https://get.docker.com | sh')
+5
View File
@@ -29,6 +29,11 @@ build_template() {
local disk="$work/disk.qcow2" local disk="$work/disk.qcow2"
cp "$IMAGE_DIR/$(basename "$IMAGE_URL")" "$disk" cp "$IMAGE_DIR/$(basename "$IMAGE_URL")" "$disk"
# The cloud image's root filesystem is only ~2 GB, too small for Docker.
# Grow the image by 4 GB and the root partition (sda1) with it.
qemu-img resize -q "$disk" +4G
virt-customize -a "$disk" --run-command "growpart /dev/sda 1 && resize2fs /dev/sda1"
# Guest agent, extra packages, optional Docker, and an empty machine-id so clones get their own DHCP lease # Guest agent, extra packages, optional Docker, and an empty machine-id so clones get their own DHCP lease
virt-customize -a "$disk" --install "qemu-guest-agent${PACKAGES:+,$PACKAGES}" virt-customize -a "$disk" --install "qemu-guest-agent${PACKAGES:+,$PACKAGES}"
if [ "${DOCKER:-0}" = 1 ]; then if [ "${DOCKER:-0}" = 1 ]; then