qemu qcow2 converting to old format

This post is mainly to remind me how to to it without having to to get the qemu-img help display up all the time.

In one of the later releases of Fedora (24 I think) the qcow2 image format changed. The only reason that was an issue for me (or that I even noticed) was the work provided laptop runs the company standard which is a customised RedHat 6; and all of a sudden disk images I build at home were unusable on Redhat 6.

So there is an occasional need to be able to convert disk images to the older format, so this is how.

[root@vmhost3 kvm]# qemu-img info fc23-x64-cloud-3G-ext4.qcow2 
image: fc23-x64-cloud-3G-ext4.qcow2
file format: qcow2
virtual size: 3.0G (3221225472 bytes)
disk size: 1.4G
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

[root@vmhost3 kvm]# qemu-img convert \
  -f qcow2 fc23-x64-cloud-3G-ext4.qcow2 \
  -O qcow2 -o compat=0.10 fc23-x64-cloud-3G-ext4-oldformat.qcow2

[root@vmhost3 kvm]# qemu-img info fc23-x64-cloud-3G-ext4-oldformat.qcow2
image: fc23-x64-cloud-3G-ext4-oldformat.qcow2
file format: qcow2
virtual size: 3.0G (3221225472 bytes)
disk size: 1.3G
cluster_size: 65536
Format specific information:
    compat: 0.10
    refcount bits: 16

Obviously it can only be run on an OS that understands the new format, as the option to convert between formats does not exist on machines that do not support the newer format.

About mark

At work, been working on Tandems for around 30yrs (programming + sysadmin), plus AIX and Solaris sysadmin also thrown in during the last 20yrs; also about 5yrs on MVS (mainly operations and automation but also smp/e work). At home I have been using linux for decades. Programming background is commercially in TAL/COBOL/SCOBOL/C(Tandem); 370 assembler(MVS); C, perl and shell scripting in *nix; and Microsoft Macro Assembler(windows).
This entry was posted in Virtual Machines. Bookmark the permalink.