Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Why does virt-clone make qcow2 images smaller

According to virt-clone man page, cloned image must be the same size as original with ---nonsparse option.

Create machine:

sudo virt-install --connect qemu:///system --name centos --memory 1024 --disk size=10,format=qcow2,sparse=no --cdrom /mnt/zalman-data/Downloads/ISO/CentOS/CentOS-7-x86_64-Minimal-1511.iso --vcpus=1,maxvcpus=4 --cpu host --network bridge=br0 --virt-type kvm --graphics vnc --os-variant centos7.0 --autostart

Check the size of installed machine:

sudo qemu-img info /mnt/zalman-data/Documents/Development/libvirt/centos.qcow2
[sudo] password for opykhalov: 
image: /mnt/zalman-data/Documents/Development/libvirt/centos.qcow2
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 1.0G
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: true
    refcount bits: 16
    corrupt: false

Clone machine:

sudo virt-clone -o centos -n test --file /mnt/zalman-data/Documents/Development/test.qcow2

Check the size of cloned image:

sudo qemu-img info /mnt/zalman-data/Documents/Development/libvirt/test.qcow2
image: /mnt/zalman-data/Documents/Development/libvirt/test.qcow2
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 1.0G
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: true
    refcount bits: 16
    corrupt: false

Clone another one with --nonsparse:

sudo virt-clone -o centos -n test2 --file /mnt/zalman-data/Documents/Development/test.qcow2 --nonsparse

Check the size of the second cloned image:

sudo qemu-img info /mnt/zalman-data/Documents/Development/libvirt/test2.qcow2
image: /mnt/zalman-data/Documents/Development/libvirt/test2.qcow2
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 1.0G
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: true
    refcount bits: 16
    corrupt: false

It's look good. But if i try to check with ls command, sizes doesn't match:

ls -lh /mnt/zalman-data/Documents/Development/libvirt/
-rw-------. 1 qemu qemu  11G Jun 25 17:46 centos.qcow2
-rw-------. 1 root root 1.1G Jun 25 18:15 test.qcow2
-rw-------. 1 root root 1.1G Jun 25 18:20 test2.qcow2