3

We can use the -c option for qemu-img to compress the qcow2 file, e.g., here, but at the cost of uncompressing it while using. Suppose I am given a compressed qcow2 file, does qemu-img have any option or command to uncompress this qcow2 file? Thanks.

1 Answer 1

2

Yes, it can.

Use qemu-img convert with the -O raw option (or -O qcow2 without the -c compression option). e.g.

qemu-img convert -f qcow2 -O raw input.qcow2 output.raw

or

qemu-img convert -f qcow2 -O qcow2 input.qcow2 output.qcow2
3
  • So, if I want to keep the qcow2 format, do I have to convert again from raw to qcow2? Is qemu-img able to uncompress directly from qcow2 to qcow2?
    – zzzhhh
    Commented Nov 23, 2021 at 3:24
  • RE: "but at the cost of uncompressing it while using" - depending on the size and compression used, reading and uncompressing a compressed file is usually faster than just reading uncompressed data. CPUs are fast and powerful, while disk I/O is slow (even on a PCI-e Gen 4 NVME drive).
    – cas
    Commented Nov 23, 2021 at 3:24
  • You could use -O qcow2 without the -c option if you wanted to retain the benefits of qcow2 (like snapshots). Personally, I use either compressed qcow2 files or ZFS zvols (with compression enabled).....and use qemu-img to convert between them if I need to.
    – cas
    Commented Nov 23, 2021 at 3:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .