Using qemu-img with compression (from emulators/qemu) yields significantly smaller images than the original mkimg one, which appears not to be compressed at all, just sparse. > qemu-img convert -S 1k -p -f raw -O qcow2 -c oci.raw oci.qcow (100.00/100%) $ ls -FGHls total 5824488 2551104 -rw-r--r-- 1 dch wheel 2.4G Apr 3 21:16 oci.mkimg.qcow2 2515616 -rw-r--r-- 1 dch wheel 6.0G Apr 3 21:17 oci.raw 757768 -rw-r--r-- 1 dch wheel 740M Apr 3 21:22 oci.qemu.qcow2
<sigh> at least make the command match the output files: > qemu-img convert -S 1k -p -f raw -O qcow2 -c oci.raw oci.qemu.qcow2
Can you check the # of blocks occupied by the mkimg and qemu-img files (e.g. stat -f%b)? Or paste a hexdump -Cv of the first few hundred bytes of each file here. AFAICT only qcow v3 actually supports compression; I wonder if the qemu-img file is in fact a "sparse" image managed by qemu rather than the filesystem. ref: https://git.qemu.org/?p=qemu.git;a=blob;f=docs/interop/qcow2.txt
Starting with a 1G file of all zeros and converting I see: $ mkimg -f qcow2 -o mkimg.qcow2.out -s gpt -p freebsd-ufs:=sparse -rw-r--r-- 1 emaste emaste 524288 Apr 6 15:28 mkimg.qcow2.out $ mkimg -f raw -o mkimg.raw.out -s gpt -p freebsd-ufs:=sparse -rw-r--r-- 1 emaste emaste 1073744384 Apr 6 15:28 mkimg.raw.out $ qemu-img convert -S 1k -p -f raw -O qcow2 -c mkimg.raw.out qemu-img.out -rw-r--r-- 1 emaste emaste 458752 Apr 6 15:30 qemu-img.out $ hexdump -Cv mkimg.qcow2.out 00000000 51 46 49 fb 00 00 00 02 00 00 00 00 00 00 00 00 |QFI.............| 00000010 00 00 00 00 00 00 00 10 00 00 00 00 40 01 00 00 |............@...| mkimg indeed produces V2 $ hexdump -Cv qemu-img.out 00000000 51 46 49 fb 00 00 00 03 00 00 00 00 00 00 00 00 |QFI.............| 00000010 00 00 00 00 00 00 00 10 00 00 00 00 40 00 0a 00 |............@...| qemu-img produces V3 We can ask for qcow2 compat: $ qemu-img convert -S 1k -p -f raw -O qcow2 -o compat=0.10 -c mkimg.raw.out qemu-img.compat.out -rw-r--r-- 1 emaste emaste 458752 Apr 6 15:36 qemu-img.compat.out $ hexdump -Cv qemu-img.compat.out 00000000 51 46 49 fb 00 00 00 02 00 00 00 00 00 00 00 00 |QFI.............| 00000010 00 00 00 00 00 00 00 10 00 00 00 00 40 00 0a 00 |............@...| It is now V2.