Pragmatic reference for creating, converting, mounting, resizing, shrinking, and migrating virtual machine disk images on Windows, Linux, and macOS, anchored to a logical architecture model.
A disk image is a block device serialized into a file, wrapped in container metadata. Every operation in this sheet acts on exactly one layer of the stack below. Knowing which layer you are touching prevents most accidents.
The container (L2) wraps the byte stream the guest sees at L3. Everything from L4 upward belongs to the guest.
Format conversion never touches partitions, filesystems, or the installed OS. The guest data stays bit-identical.
2
Conversion changes only L2.
qemu-img convert rewrites allocation metadata and re-packs allocated clusters. It also restores sparseness by skipping zero clusters.
3
Mounting an image on the host means re-implementing L3 in the host kernel.
Linux: loop or nbd device. Windows: Attach VHD. macOS: hdiutil attach. The host then parses L4 to L6 like any physical disk.
4
Space reclamation must traverse the full stack.
Guest trim (L6) → discard on the virtual controller (L3) → cluster unmap in the container (L2) → hole punch on the host FS (L1). Any layer that drops the discard leaves the file bloated.
5
Copy-on-write can live at L2 (qcow2, VMDK deltas, AVHDX), at L1 (ZFS, Btrfs, LVM-thin), or both.
Pick one layer to own snapshots. Stacked CoW multiplies write amplification and fragmentation.
2. Format reference
Format
Extension
Native ecosystem
Max virtual size
Allocation
Snapshot mechanism
qemu-img driver name
Notes
Raw
.img, .raw
Universal (every hypervisor, dd, loop)
Host FS limit
Sparse via FS holes, or fully preallocated
None at L2; use LVM/ZFS/FS at L1
raw
Zero metadata overhead, fastest, trivially mountable. Sparseness is fragile in transit.
QCOW2
.qcow2
QEMU/KVM, Proxmox, UTM, libvirt
Effectively unlimited (EB scale)
CoW clusters, 64 KiB default
Internal snapshots and external overlays with backing files
qcow2
Compression (zlib, zstd), LUKS encryption, dirty bitmaps for incremental backup. The feature-rich choice.
VMDK
.vmdk
VMware ESXi, Workstation, Fusion
62 TB (ESXi 5.5+)
Sparse (growable) or flat; thin, lazy zeroed, eager zeroed on VMFS
Delta extents (disk-000001.vmdk)
vmdk
A descriptor plus one or more extents. Subformat matters: monolithicSparse, monolithicFlat, twoGbMaxExtentSparse/Flat, streamOptimized (the OVA payload).
VHD
.vhd
Legacy Microsoft, Azure upload
2040 GB (~2 TB)
Fixed, dynamic, differencing
Differencing disks (parent/child)
vpc
Footer at end of file. Azure still requires fixed-size VHD for image upload.
VHDX
.vhdx
Hyper-V 2012+, native Windows mount
64 TB
Fixed, dynamic, differencing
AVHDX checkpoint chain
vhdx
Internal log makes it resilient to power loss. Supports 4 KiB logical sectors. WSL2 distro disks are VHDX.
VDI
.vdi
VirtualBox
Multi-TB
Dynamic or fixed
VirtualBox snapshot machinery
vdi
Simple and fine inside VirtualBox; convert when leaving the ecosystem.
Parallels HDD
.hdd (inside .pvm bundle)
Parallels Desktop (macOS)
Multi-TB
Expanding or plain
Parallels snapshots in the .pvm bundle
parallels
Managed with prl_disk_tool.
DMG family
.dmg, .sparseimage, .sparsebundle
macOS disk images (not hypervisor formats, same L2 idea)
qemu-img snapshot -l/-c NAME/-a NAME/-d NAME disk.qcow2
Check and repair qcow2 metadata
qemu-img check -r all disk.qcow2
Repoint an overlay to a moved backing file
qemu-img rebase -u -b /new/path/base.qcow2 -F qcow2 overlay.qcow2
Merge an overlay down into its backing file
qemu-img commit overlay.qcow2
Predict required size before converting
qemu-img measure -O qcow2 in.vmdk
Compare two images content-wise
qemu-img compare a.qcow2 b.raw
Preallocation modes for -o preallocation=: off (thin), metadata (qcow2 tables only), falloc (fast reserve), full (write zeros, best latency).
4. Per-OS toolbox
4.1 Windows
VHD and VHDX are first-class citizens: Explorer mounts them on double-click, Disk Management has Attach VHD, and the Hyper-V PowerShell module does the rest. Everything else gets handled by qemu-img.
QEMU backend uses qcow2; the Apple Virtualization backend uses raw .img (and ASIF on Tahoe). Both sit inside the .utm bundle.
Mounting qcow2 on the host
No nbd kernel driver exists. Convert to raw and hdiutil attach, or run guestmount inside a Lima/Docker Linux VM, or attach the disk to a throwaway UTM VM.
Guest trim
Works in UTM/QEMU with virtio and discard enabled, then fstrim (Linux guest) or defrag /L (Windows guest), then re-sparsify or compact on the host.
5. Conversion
Pre-flight checklist
Step
Why
Shut the VM down cleanly
Converting a running or crash-state disk produces a dirty filesystem
Consolidate or delete snapshots first
Converters typically read one layer; orphaned chains lose data or fail
Record firmware type (BIOS vs UEFI) and controller type
More migrations break on firmware and driver mismatch than on disk bits
Install target-platform drivers in advance (virtio-win, Hyper-V ICs, VMware Tools) or plan to use virt-v2v
A Windows guest without the boot-critical storage driver blue-screens with INACCESSIBLE_BOOT_DEVICE
Verify free space ≥ virtual size of the source
qemu-img measure predicts the target size
Work on a copy
Conversion is read-only on the source, but mistakes with paths are not
Conversion matrix (qemu-img does almost everything)