- Cheat Sheet and Example is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools






KVM CLI Commands Cheet Sheat and KVM Configuration Examples

KVM : How to create/change/check KVM Images (raw, qcow2)


Image types

  • 'disk size = consumption size' is non-sparse.
  • 'disk size > consumption size' is sparse.
  • Performance : raw (non sparse) > raw (sparse) > qcow2
    raw (non sparse) is the best high speed.
  • qcow2 can use snapshots.
raw (sparse)
raw (non sparse)
(default) the raw format is a plain binary image of the disc image, and is very portable. On filesystems that support sparse files, images in this format only use the space actually used by the data recorded in them.
qcow2 QEMU copy-on-write format with a range of special features, including the ability to take multiple snapshots, smaller images on filesystems that don't support sparse files, optional AES encryption, and optional zlib compression

Checking Image

qemu-img info FILE

How to create a KVM Image File


dd if=/dev/zero of=raw-nonsparce.img bs=1M count=8196   #8G
dd if=/dev/zero of=raw-nonsparce.img bs=1M count=40980   #40G
dd if=/dev/zero of=raw-nonsparce.img bs=1M count=51225   #50G


qemu-img create -f raw raw-sparce.img 8G


qemu-img create -f qcow2 qcow2.img 8G

How to change Image Files

qcow2, raw (non-sparse) -> raw (sparse)

qemu-img convert -O raw SRC.img DST.img

raw (sparse, non-sparse) -> qcow2

qemu-img convert -O qcow2 SRC.img DST.img

raw (sparse) -> raw (non-spase)

cp --sparse=never SRC.img DST.img


How to expand image files

# qemu-img resize raw.img +8GB

middleware/virtualization/kvm/convert_image.html.txt ยท Last modified: 2017/05/06 by admin

Page Tools