QCOW2的几种预分配规则创建时间对比

/ 0评 / 0

主要有以下几种策略,都在同一个SSD上测试.

分配速度测试:

root@debian:/var/lib/libvirt/images# time qemu-img create -f qcow2 -o preallocation=off /var/lib/libvirt/images/seedbox.qcow2 500G
Formatting '/var/lib/libvirt/images/seedbox.qcow2', fmt=qcow2 size=536870912000 cluster_size=65536 preallocation=off lazy_refcounts=off refcount_bits=16

real    0m0.144s
user    0m0.000s
sys     0m0.029s
root@debian:/var/lib/libvirt/images# time qemu-img create -f qcow2 -o preallocation=metadata /var/lib/libvirt/images/seedbox.qcow2 500G
Formatting '/var/lib/libvirt/images/seedbox.qcow2', fmt=qcow2 size=536870912000 cluster_size=65536 preallocation=metadata lazy_refcounts=off refcount_bits=16

real    1m19.068s
user    0m3.763s
sys     0m1.151s
root@debian:/var/lib/libvirt/images# time qemu-img create -f qcow2 -o preallocation=falloc /var/lib/libvirt/images/seedbox.qcow2 500G
Formatting '/var/lib/libvirt/images/seedbox.qcow2', fmt=qcow2 size=536870912000 cluster_size=65536 preallocation=falloc lazy_refcounts=off refcount_bits=16

real    1m28.153s
user    0m3.723s
sys     0m1.766s
root@debian:/var/lib/libvirt/images# time qemu-img create -f qcow2 -o preallocation=full /var/lib/libvirt/images/seedbox.qcow2 500G
Formatting '/var/lib/libvirt/images/seedbox.qcow2', fmt=qcow2 size=536870912000 cluster_size=65536 preallocation=falloc lazy_refcounts=off refcount_bits=16

real    43m11.214s
user    0m3.721s
sys     0m1.216s

所以除非特别纠结,不然还是falloc最划算.

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注