大网数据广告活动
服务器运维问答

How to create a qcow2 file that is not thin provisioned?

· 52CE 我爱测

When I do the below then the qcow2 file is less than 200KB. # qemu-img create -f qcow2 /var/lib/libvirt/images/urb-dat0.qcow2 10G # du -hsc /var/lib/libvirt/images/urb-dat0.qcow2 196K /var/lib/libvirt/images/urb-dat0.qcow2 If I a…

问题原文

原帖链接 · Jasmine Lognnes · CC BY-SA 3.0

When I do the below then the qcow2 file is less than 200KB.

# qemu-img create -f qcow2 /var/lib/libvirt/images/urb-dat0.qcow2 10G
# du -hsc /var/lib/libvirt/images/urb-dat0.qcow2
196K    /var/lib/libvirt/images/urb-dat0.qcow2

If I attach it to a KVM guest and fdisk -l

Disk /dev/vdb: 0 MB, 197120 bytes, 385 sectors

Question

How to make a 10GB qcow2 file that is not thin provisioned?

已采纳解答

原帖链接 · Craig Watson · CC BY-SA 3.0

You can use the preallocation option.

qemu-img create -o preallocation=full -f qcow2 /var/lib/libvirt/images/urb-dat0.qcow2 10G

Reference: https://linux.die.net/man/1/qemu-img

Preallocation mode (allowed values: off, metadata, full). An image with preallocated metadata is initially larger but can improve performance when the image needs to grow. Full preallocation additionally writes zeros to the whole image in order to preallocate lower layers (e.g. the file system containing the image file) as well. Note that full preallocation writes to every byte of the virtual disk, so it can take a long time for large images.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-03-28)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。