qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: qemu-img convert: Compression can not be disabled when converting fr


From: Nir Soffer
Subject: Re: qemu-img convert: Compression can not be disabled when converting from .qcow2 to .raw
Date: Fri, 21 Jun 2024 18:23:33 +0300

On Fri, Jun 21, 2024 at 5:48 PM Sven Ott <sven.ott@fau.de> wrote:
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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]