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

qemu-img convert -f qcow2 -O raw $GUEST_IMG.img $GUEST_IMG.raw

```

The problem is that the convert command throws away the 0-bytes which have been appended earlier, leaving me with a .raw image of the original size. As per the man page, the resulting image can be optionally compressed with the -c flag, indicating that not providing said flag would lead to an uncompressed resulting image.

I'm on Debian on x86_64; I've tried the qemu-img version 6.2 and 8.2 unsuccessfully so far.

Any help would be appreciated!

Sven



Reply via email to