tools: nm-in-vm: change default image size

Images of qcow2 format dynamically grow up to the maximum size that they
have been configured at creation time. Because of this, higher size can
be selected without wasting unnecesary space in the host. Rise image
size to 20G.

Also, allow to set an empty value to IMAGE_SIZE, and don't resize in
that case. This is useful because virt-resize fails with some guest
partition layouts (like with ubuntu-20.04).
This commit is contained in:
Íñigo Huguet 2023-08-04 11:29:29 +02:00
parent 28cb8024e3
commit f9cfe80b56

View file

@ -65,7 +65,7 @@ fi
VM=${VM:="nm"} VM=${VM:="nm"}
OS_VERSION=${OS_VERSION:=} OS_VERSION=${OS_VERSION:=}
RAM=${RAM:=2048} RAM=${RAM:=2048}
IMAGE_SIZE=${IMAGE_SIZE:=10G} IMAGE_SIZE=${IMAGE_SIZE=20G}
ROOT_PASSWORD=${ROOT_PASSWORD:=nm} ROOT_PASSWORD=${ROOT_PASSWORD:=nm}
LIBVIRT_POOL=${LIBVIRT_POOL:=default} # only useful if BASEDIR_VM_IMAGE is empty LIBVIRT_POOL=${LIBVIRT_POOL:=default} # only useful if BASEDIR_VM_IMAGE is empty
BASEDIR_VM_IMAGE=${BASEDIR_VM_IMAGE:=} BASEDIR_VM_IMAGE=${BASEDIR_VM_IMAGE:=}
@ -104,6 +104,8 @@ fi
do_build() { do_build() {
local t=$'\t' local t=$'\t'
local ram
local size
local os_variant local os_variant
local nm_ci_build_args local nm_ci_build_args
local nm_ci_install_args local nm_ci_install_args
@ -141,6 +143,10 @@ do_build() {
return 0 return 0
fi fi
if [[ -n $IMAGE_SIZE ]]; then
size=(--size "$IMAGE_SIZE")
fi
if [[ -n $BASEDIR_NM_CI ]]; then if [[ -n $BASEDIR_NM_CI ]]; then
nm_ci_build_args=( nm_ci_build_args=(
--mkdir "$BASEDIR_NM_CI" --mkdir "$BASEDIR_NM_CI"
@ -223,7 +229,7 @@ do_build() {
echo "Creating VM" echo "Creating VM"
echo " - VM NAME: $VM" echo " - VM NAME: $VM"
echo " - OS VERSION: $OS_VERSION" echo " - OS VERSION: $OS_VERSION"
echo " - SIZE: $IMAGE_SIZE" echo " - SIZE: $([[ -n $IMAGE_SIZE ]] && echo "$IMAGE_SIZE" || echo "don't resize")"
echo " - RAM: $RAM" echo " - RAM: $RAM"
echo " - ROOT PASSWORD: $ROOT_PASSWORD" echo " - ROOT PASSWORD: $ROOT_PASSWORD"
echo " - IMAGE PATH: $basedir_vm_image/$vm_image_file" echo " - IMAGE PATH: $basedir_vm_image/$vm_image_file"
@ -233,7 +239,7 @@ do_build() {
virt-builder "$OS_VERSION" \ virt-builder "$OS_VERSION" \
--output "$basedir_vm_image/$vm_image_file" \ --output "$basedir_vm_image/$vm_image_file" \
--size "$IMAGE_SIZE" \ "${size[@]}" \
--format qcow2 \ --format qcow2 \
--arch x86_64 \ --arch x86_64 \
--hostname "$VM" \ --hostname "$VM" \