cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Cloud



Etc


Reference














.

middleware:virtualization:kvm:convert_image.html



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

Reference

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

raw(non-sparse)

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

raw(sparse)

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

qcow2

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


TIPS

How to expand image files




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

Page Tools