Re: qemu-img convert: Compression can not be disabled when converting from .qcow2 to .raw
Thanks all, it works with qemu-img resize! On 6/21/24 16:46, Sven Ott 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 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
Re: qemu-img convert: Compression can not be disabled when converting from .qcow2 to .raw
On Fri, Jun 21, 2024 at 5:48 PM Sven Ott 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
Re: I doubt here
Only if the BIOS matches the virtual motherboard provided by Qemu . For example, if the BIOS tries to configure a register controlling the USB controller on the real motherboard, it will only work if the virtual motherboard has the same USB controller at the same bus address. The Qemu virtual motherboards are based on specific old Intel chipsets combined with custom virtual chips such as the paravirtual disk controller. It's the same problem as installing a BIOS from a completely different motherboard on a different real motherboard, except you don't need a soldering iron to repair the damage to virtual hardware. On 2024-06-21 15:39, Lucas Machado Zainote wrote: Can I boot a nomral cumputer bios in qemu ? I mean a .bin file. let's say I have a motherborad bios file in this format can I use qemu to test it? thank you for the great software. Lucas Machado Zainote lucasmzain...@aol.com Enjoy Jakob -- Jakob Bohm, CIO, Partner, WiseMo A/S. https://www.wisemo.com Transformervej 29, 2860 Søborg, Denmark. Direct +45 31 13 16 10 This public discussion message is non-binding and may contain errors. WiseMo - Remote Service Management for PCs, Phones and Embedded
I doubt here
Can I boot a nomral cumputer bios in qemu ? I mean a .bin file. let's say I have a motherborad bios file in this format can I use qemu to test it? thank you for the great software. Lucas Machado Zainote lucasmzain...@aol.com
Re: qemu-img convert: Compression can not be disabled when converting from .qcow2 to .raw
Dear Sven, Note that qcow2 files contain data saying how large the virtual disk is and what blocks in the virtual disk correspond to what blocks in the qcow2 file. Thus adding extra all-0 blocks at the end of a qcow2 file using generic file manipulation tools like truncate or dd will not change the size or content of the virtual disk image that can be extracted as a raw file. Instead you need to resize the virtual disk inside the qcow2 file with "qemu-img resize" subcommand before converting to a raw image. Alternatively, you can use the generic file tools to change the size of the raw file directly. On 2024-06-21 16:46, Sven Ott 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 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 Enjoy Jakob -- Jakob Bohm, CIO, Partner, WiseMo A/S. https://www.wisemo.com Transformervej 29, 2860 Søborg, Denmark. Direct +45 31 13 16 10 This public discussion message is non-binding and may contain errors. WiseMo - Remote Service Management for PCs, Phones and Embedded
Re: qemu-img convert: Compression can not be disabled when converting from .qcow2 to .raw
Maybe try first qemu-img resize then use qemu-img convert On Fri, 21 Jun, 2024, 20:18 Sven Ott, 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 > > 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 > > > >
qemu-img convert: Compression can not be disabled when converting from .qcow2 to .raw
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