Loading...

We've detected that your browser language is Chinese. Would you like to visit our Chinese website? [ Dismiss ]
By: Emma

When deploying virtual machines in KVM or QEMU, the choice of virtual disk format comes up early. In most cases, it comes down to raw and QCOW2. Both support the same guest operating systems, but raw prioritizes I/O performance while QCOW2 trades a small overhead for features like snapshots, thin provisioning, and compression.

The format you choose affects VM performance, disk space usage, backup workflows, and day-to-day management. This guide breaks down the differences and helps you pick the right one for your workload.

What Are Raw and QCOW2 Disk Images?

To choose between the two formats, it helps to understand how each one stores and manages virtual disk data on the host.

What Is a Raw Disk Image

A raw disk image is the simplest virtual disk format in KVM/QEMU. It stores the exact sector-by-sector contents of a virtual disk with no added structure or metadata layer.

what is raw disk image

How Raw Images Work

Raw images map virtual disk blocks directly to host storage. There is no internal metadata, no block index, and no snapshot table. When a VM writes data, the hypervisor passes it straight through to the corresponding location on disk, which is why raw images deliver near-native I/O performance.

Sparse File Behavior

Raw images are not always fully allocated. When created as a sparse file, the image only consumes physical space as the guest writes data. A 100 GB sparse raw image might occupy just 5 GB after a fresh OS install.

One caveat: some copy tools fill empty blocks with real data during migration, expanding the image to its full virtual size on the destination.

What Is a QCOW2 Disk Image

QCOW2 (QEMU Copy-On-Write version 2) is the native disk image format for QEMU. Unlike raw, it trades a small performance overhead for built-in snapshots, thin provisioning, compression, encryption, and backing file support.

what is qcow2 disk image

Copy-on-Write Architecture and Cluster Allocation

QCOW2 organizes data into 64 KB clusters and only allocates physical storage when the guest writes to a cluster. This means the image grows on demand rather than consuming its full provisioned size upfront.

Backing files work the same way: QCOW2 records only the changes from the base image, leaving the original untouched. This makes it the standard choice for VM templates and linked clones.

The L1/L2 Table Lookup Mechanism

QCOW2 uses a two-level index — an L1 table pointing to L2 tables, which then map to the actual data clusters. Every read or write requires walking this index before reaching the data, which adds latency compared to raw’s direct block mapping. The impact is small for sequential I/O but more noticeable under heavy random workloads.

Raw vs QCOW2: Core Feature Comparison

The two formats approach storage differently. raw keeps things simple and fast; QCOW2 adds a feature layer on top. The table below summarizes the key differences.

Feature raw QCOW2
Primary Advantage Maximum I/O performance Advanced storage management
Storage Allocation Fully allocated or sparse Native thin provisioning
Native Snapshots Not supported Supported (internal and external)
Backing Files Not supported Supported
Native Encryption Not supported Supported (LUKS)
Native Compression Not supported Supported (zlib / zstd)

Storage Allocation and Thin Provisioning

Raw images can be created as sparse files, which gives basic thin provisioning at the file system level. The downside is that sparse behavior depends on the host file system and the tools used — some copy or backup utilities will fill empty blocks with real data during transfer, inflating the image to its full virtual size.

QCOW2 handles thin provisioning at the image level. QEMU manages cluster allocation directly, so the image grows on demand regardless of which host file system or transfer tool is used.

Snapshot Support and Backing File Chains

Raw images have no built-in snapshot support. Snapshots for raw-based VMs rely on external mechanisms such as LVM snapshots, Ceph snapshots, or storage array features.

QCOW2 supports both internal and external snapshots natively, and also supports backing files. Multiple VMs can share a single read-only base image and store only their individual changes in separate overlay files, which can significantly cut storage usage in large-scale deployments.

Compression and Encryption

Raw has no native compression or encryption. These need to be handled at the host file system, storage platform, or guest OS level.

QCOW2 supports LUKS encryption and compression via zlib or zstd. Both are useful when archiving VM templates or maintaining golden images where storage efficiency matters.

Live Migration and Online Resize

Both formats support live migration between KVM hosts given the right shared storage or migration infrastructure. Raw may have a slight edge in migration overhead since it carries no metadata, but in practice, the difference is small, and network bandwidth is usually the bottleneck.

For online resize, both formats support expanding a virtual disk while the VM is running. QCOW2 updates its metadata automatically; raw relies on the underlying storage and guest tools to recognize the additional space.

Raw vs QCOW2: Performance Comparison

Performance is one of the most common factors when choosing between raw and QCOW2. Raw has a structural advantage because it provides a simpler storage path, but the practical performance difference depends heavily on workload, storage backend, and configuration.

How Big Is the Performance Gap?

Under sequential workloads on preallocated storage, the performance difference between raw and QCOW2 is often small. Both formats can deliver similar throughput for read-heavy workloads or environments with moderate I/O demands.

The gap becomes more noticeable under scenarios such as:

  • Heavy random write workloads
  • Deep QCOW2 snapshot chains
  • Highly fragmented QCOW2 images
  • Slower storage backends, such as HDD-based or network storage

What Drives the Performance Difference?

Raw maps virtual disk blocks directly to host storage with no intermediate layer, keeping the I/O path as short as possible. QCOW2 adds processing at several points:

  • Metadata translation. Before each write, QEMU consults the L1 and L2 tables to locate or allocate the correct cluster. If the cluster is new, the metadata tables are also updated during the write.
  • Fragmentation. QCOW2 allocates clusters dynamically, so data is not always written contiguously. On HDD-based systems, this increases seek overhead as the image fills up.
  • Snapshot chain depth. Long backing file chains require QEMU to traverse multiple metadata layers to locate older data blocks, increasing read latency.

Under random write-heavy workloads, these factors compound and the latency difference compared with raw becomes more pronounced.

How to Improve QCOW2 Performance

If you need QCOW2 features but want to reduce the performance gap compared with raw, several QEMU tuning options can help:

  • Preallocation (preallocation=metadata or preallocation=falloc): Reduces runtime allocation overhead by preparing metadata structures or allocating storage space during image creation.
  • Cache Mode (cache=none): Bypasses the host page cache to avoid double buffering between the guest and host. In some SSD-based environments, cache=writeback can improve throughput by grouping write operations.
  • Asynchronous I/O (aio=native or aio=io_uring): Allows QEMU to process I/O requests more efficiently with reduced kernel overhead.
  • L2 Cache Size (l2-cache-size): Keeps more QCOW2 metadata tables in memory, reducing additional disk accesses during address translation.

When Does the Difference Actually Matter?

Raw’s performance advantage matters most for I/O-intensive workloads where storage latency directly affects application response times. Examples include high-transaction databases, busy message queues, and large-scale log processing systems.

For general-purpose virtual machines, development environments, and test labs, the performance difference is often small enough that QCOW2’s operational benefits (snapshots, thin provisioning, and backing files) provide greater value than the additional performance of raw.

Raw vs QCOW2: Which Should You Choose?

Performance is only one factor. The right format depends on your storage architecture, operational workflows, backup strategy, and workload requirements.

Quick Decision Guide

Choose Raw if you:

  • Need maximum I/O performance for latency-sensitive workloads
  • Manage snapshots and backups at the storage layer (SAN, Ceph, or LVM)
  • Run transaction-heavy databases or other I/O-intensive applications
  • Want the simplest storage path with minimal metadata overhead

Choose QCOW2 if you:

  • Need built-in VM snapshot capabilities
  • Want thin provisioning to improve storage efficiency
  • Use base images or templates to deploy multiple VMs
  • Need built-in encryption, compression, or backing file support

Which Format Fits Your Use Case?

The best format depends on what you are running. Here is a breakdown by common scenario.

1. Database and High-I/O Workloads

For high-transaction databases like MySQL, Oracle, or PostgreSQL, raw is the safer default. If your storage layer already handles snapshots via LVM, Ceph, or a SAN, you get the performance benefit of raw without giving up snapshot capability.

2. General-Purpose VMs

QCOW2 works well here. Taking a snapshot before a system update and rolling back if something goes wrong is much simpler with QCOW2 than coordinating a storage-layer snapshot for a raw image.

3. VM Templates

QCOW2’s backing file mechanism lets multiple VMs share a single base image, with each instance storing only its own changes. This is not possible with raw without duplicating the full image for every VM.

4. Cloud Platforms

Most cloud platforms, including OpenStack, expect QCOW2 by default. Using raw may require format conversion before upload or deployment, adding an extra step to your workflow.

5. Test and Lab

The ability to snapshot, test, and roll back without touching external storage tooling is the main reason QCOW2 is the standard choice in lab setups.

How to Convert Between Raw and QCOW2

If your storage strategy or platform requirements change, you can convert existing disk images using qemu-img, the standard QEMU utility for virtual disk management.

qemu-img Convert Command Reference

Shut down the VM before converting, or ensure the image is not being actively written to.

To convert raw to QCOW2:

bash
qemu-img convert -f raw -O qcow2 source_image.raw destination_image.qcow2 -p

To convert QCOW2 to raw:

bash
qemu-img convert -f qcow2 -O raw source_image.qcow2 destination_image.raw -p

Note that converting QCOW2 to raw can significantly increase the physical file size if the destination file system does not support sparse files.

Converting for Cross-Platform Migration

When migrating between VMware and KVM environments, qemu-img handles VMDK-to-QCOW2 conversion as well.

To convert VMDK to QCOW2:

bash
qemu-img convert -f vmdk -O qcow2 source_disk.vmdk destination_disk.qcow2 -p

To convert QCOW2 to VMDK:

bash
qemu-img convert -f qcow2 -O vmdk source_disk.qcow2 destination_disk.vmdk -p

For Windows VMs, install VirtIO drivers before conversion. Without them, the VM may not boot after moving to a KVM environment.

Verifying Integrity After Conversion

Before attaching the converted image to a VM, run a quick check:

bash
qemu-img info destination_image.qcow2
qemu-img check -f qcow2 destination_image.qcow2

qemu-img info shows the image format, virtual size, actual disk usage, and backing file configuration. qemu-img check validates QCOW2 metadata and reports issues such as leaked clusters or reference count errors.

How to Backup and Take Snapshots for Raw and QCOW2

Raw and QCOW2 require different backup approaches. The format you choose affects which tools and strategies are available to you.

Backing Up Raw Images

Raw images have no built-in snapshot support, so backups depend on the storage or virtualization layer. For an offline backup, you can copy a powered-off image with dd:

bash
dd if=source_image.raw of=/backup/destination_image.raw bs=1M status=progress

Copying a raw image while the VM is running risks an inconsistent backup. In production, use storage-level snapshots (LVM, Ceph, or SAN) or virtualization platform APIs to capture a consistent state without downtime.

Backing Up QCOW2 Images

QCOW2’s built-in snapshot support gives you more flexibility. External snapshots are generally preferred over internal ones in production because they are easier to manage and integrate with backup workflows.

QCOW2’s copy-on-write architecture also enables incremental backups: only changed data since the last snapshot needs to be captured, which reduces backup size and time.

Avoid Long Snapshot Chains

Snapshots are useful for short-term protection but should not replace proper backups. As the chain grows, QEMU has to traverse more backing file layers to read data, which increases latency and degrades storage performance. Consolidate or remove snapshots regularly once they are no longer needed.

Enterprise VM Backup with i2Backup

Manual backup workflows become harder to maintain as your VM environment grows. i2Backup automates this through agentless backup using native virtualization platform APIs, supporting both raw and QCOW2-based VMs.

Instead of full image copies each time, i2Backup uses block-level change tracking to capture only what has changed, reducing backup windows and storage consumption. For recovery, it supports instant VM recovery by mounting the backup image directly, as well as file-level restore for individual files or folders without recovering the entire VM.

Conclusion

Raw and QCOW2 serve different needs. Raw gives you a simpler I/O path and better performance under heavy workloads. QCOW2 trades a small overhead for snapshots, thin provisioning, and backing file support that make VM management easier day to day.

For most general-purpose deployments, QCOW2 is the practical default. For latency-sensitive workloads like high-transaction databases, raw is worth the trade-off, especially if your storage layer already handles snapshots independently.

Whichever format you use, make sure your backup strategy does not rely on snapshots alone. Snapshots are useful checkpoints, but they are not a substitute for proper, recoverable backups.

Emma is the bridge between complex engineering and the people who need it. As a content creator at Info2soft, she spends her days translating "tech-speak" into clear, actionable stories about data resilience. She’s not just documenting software; she's uncovering how data replication and recovery actually change the way businesses run.

More Related Articles

Table of Contents:
Stay Updated on Latest Tips
Subscribe to our newsletter for the latest insights, news, exclusive content. You can unsubscribe at any time.
Subscribe
Ready to Enhance Business Data Security?
Start a 60-day free trial or view demo to see how Info2soft protects enterprise data.
Please fill out the form and submit it, our customer service representative will contact you soon.
By submitting this form, I confirm that I have read and agree to the Privacy Notice.
{{ isSubmitting ? 'Submitting...' : 'Submit' }}