Hi, I want to mount a VM image to a loop device and give it some excess
space.
To do so, I download a .qcow2 file, add some 0 bytes with truncate, and
then convert the image from QCOW2 to RAW format with qemu-img convert,
like so:
```
GUEST_IMG=focal-server-cloudimg-amd64
wget https://cloud-images.ubuntu.com/focal/current/$GUEST_IMG
truncate -s 5G $GUEST_IMG.img
This is not needed, and ineffective...
qemu-img convert -f qcow2 -O raw $GUEST_IMG.img $GUEST_IMG.raw
Since the first thing done in this command is truncating the target image to 0 bytes.
You can use -n to avoid creation of the target image and use your image, but this is also not
needed.
You can convert the image:
qemu-img convert -f qccow2 -O raw src.qcow2 dst.raw
and then resize the raw image:
qmeu-img resize dst.raw newsize
You can also resize before converting, it does not matter if you resize before or after.
Note that you will have to grow the pv/lv/filessystem inside the guest to use the additional space.
Nir