Resize A QEMU Disk Image
1. Install
guestfs-tools
$ apt-get update
$ apt-get install guestfs-tools
2. Download an image
Download an image from https://cdimage.debian.org/images/cloud/.
3. List partitions
Check the image disk partitions to see which partition needs resizing.
$ virt-filesystems --long -h --all -a debian-12-nocloud-amd64.qcow2
4. Create output container
$ qemu-img create -f qcow2 -o preallocation=metadata debian-12-nocloud-amd64-resized.qcow2 20G
5. Generate resized image
$ virt-resize --expand /dev/sda1 debian-12-nocloud-amd64.qcow2 debian-12-nocloud-amd64-resized.qcow2
Conclusion
You can now open debian-12-nocloud-amd64-resized.qcow2
with a virtual machine program and the disk size will be 20G.
References
virt-resize
manpage
$ man virt-resize