qcow2 file to big

q16marvin

Renowned Member
Jul 16, 2013
52
0
71
Hi,

root@proxmox2:/var/lib/vz/images/100# qemu-img info vm-100-disk-2.qcow2
image: vm-100-disk-2.qcow2
file format: qcow2
virtual size: 150G (161061273600 bytes)
disk size: 247G
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false


you see the virtual size is aber 150G, but disk size is 247.. so realy to big and my bare metal disk is full ...

how can i shrink this?

Thx!

Erik
 
I saw that even if i create qcow format for new machine ltes say size of 50GB, it will create file 50GB.
When i will execute conversion that i described below, the image shrink from 50GB to somethking like 1 KB and then when i am installing linux on it, it grows.
Anyway this is the way to save space :)

you can shutdown VM
and do this:
qemu-img convert -c -O qcow2 vm-100-disk-2.qcow2 vm-100-disk-2.qcow2.new
See if size recuded.
mv vm-100-disk-2.qcow2 vm-100-disk-2.qcow2.old
mv vm-100-disk-2.qcow2.new vm-100-disk-2.qcow2
 
In general, it's best to also use dd to create a file filled with zeroes then deleting it before shutdown.
dd of=filetodelete if=/dev/zero bs=10M ; echo > filtodelete; rm filtodelete; halt

So to speak.