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.
Asked
Active
Viewed 2,601 times
2
zzzhhh
- 135
- 1
- 6
1 Answers
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
cas
- 1
- 7
- 119
- 185
-
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 Nov 23 '21 at 03: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 Nov 23 '21 at 03: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 Nov 23 '21 at 03:26