Raw vs Qcow2 Disk Images in QEMU/KVM

Raw vs Qcow2: Qemu/KVM provides support for various image formats. The two major disk image formats, widely recommended and used are raw and qcow2. Thus, lets understand what they are and their differences.

To begin with, one of the important part of virtualization is storage. Storage allows virtualized environment to read and write data over variety of different methods. Furthermore, disk Image is widely popular method of storage in virtualization.

A disk image in virtualization represents a block of data on hard disk. Moreover, it will be a virtual disk for a virtualized environment. Hence, this method of storage is a File-based storage.

RAW Disk Images

Raw disk image format is default format in Qemu.

Pros of using RAW Disk Images:

  1. It is simple and portable to any other machine.
  2. It represents default binary format of a hard disk.
  3. Nearly raw performance then other formats, as it has very little overhead and no metadata and at last,
  4. Only data written will occupy space, rest of space will be filled with zeros, as it is a sparse file.

Cons of using RAW Disk Images:

  1. Does not have other features like compression, AES encryption and snapshot.
  2. Backup requires full disk-up, as no incremental back-upand at last,
  3. Deleted files still occupy space and have to be removed.


qemu-img create -f raw /var/lib/libvirt/images/sample1.img 5G

For Preallocating size

qemu-img create -f raw -o preallocation=full /var/lib/libvirt/images/sample1.img 5G

Lastly, to verify

qemu-img info /var/lib/libvirt/images/sample1.img
qcow2 Disk Images

qcow2 is copy on write image disk, where constant size units called clusters compose a file. A cluster holds both data as well as image metadata.

Pros of using qcow2 Disk Images:

  1. Smaller images are produced, as no sparse file.
  2. It provides zlib based compression.
  3. For data security, AES encryption can be used to protect disk image.
  4. Multiple Virtual Machine snapshots are offered, as incremental back-up.
  5. Small Cluster Size improve image file size, and larger can be used for better performance and at last,
  6. Larger Preallocation increases performance as image size increases to grow.

Cons of using qcow2 Disk Images::

  1. Very slight performance loss in comparison to raw disk image, due to metadata, compression and encryption and,
  2. One needs to use fstrim to trim image file, as deleted files does increases image size.


qemu-img create -f qcow2 /var/lib/libvirt/images/sample1.qcow2 5G

For Cluster size image of 2M

qemu-img create -f qcow2 -o cluster_size=2M /var/lib/libvirt/images/sample1.qcow2 5G

For Preallocated size

qemu-img create -f qcow2 -o preallocation=full /var/lib/libvirt/images/sample1.qcow2 5G

Lastly, to verify

qemu-img info /var/lib/libvirt/images/sample1.qcow2

In conclusion, Raw vs Qcow2: both have their pros and cons, while raw offers pure performance whereas qcow2 offers practical and useful features. In the end, use of image format comes down to use case scenario.