#! /bin/bash -x MACHINE_NAME="my-machine" # whatever your machine or 'domain' in the Libvirt jargon BACKUP_IMAGE="/var/lib/libvirt/images/${MACHINE_NAME}.qcow2-backup" CURRENT_IMAGE="/var/lib/libvirt/images/${MACHINE_NAME}.qcow2" PRIMARY_DISK="/dev/sda1" # The partition to enlarge # Make image 40G in size: qemu-img create -f qcow2 -o preallocation=metadata ${CURRENT_IMAGE} 40G