QCOW2 virtual size lowering
I'm trying to get the virtual size of a qcow2
container down so that it can fit in a openstack flavor with 10GB disk.
root@node-10:~# qemu-img info zztop.qcow
image: zztop.qcow
file format: qcow2
virtual size: 80G (85899345920 bytes)
disk size: 2.6G
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
I follow the guide here and fill the end of the disk with zeros then run qemu-img convert -O qcow2
.
The resulting qcow2 however retains the same disk size and virtual size.
How do I lower the virtual size of a qcow2 so that it can fit in a openstack flavor smaller than 80GB?
Solution 1:
If you want to shrink the virtual size, you need to use virt-resize
Solution 2:
- You need to convert the qcow2 image to raw
qemu-img convert -O raw guest.img guest.raw
- Then resize the raw file
qemu-img resize guest.raw 3G
- Then convert it back to qcow2
qemu-img convert -O qcow2 -o compat=0.10 guest.raw guest.img
- Then run the guest and resize your file system