Proxmox Snapshot and Rollback Deep Dive
The word "snapshot" in Proxmox means something fundamentally different depending on the disk format, and mixing the two is the most common source of misconfiguration in local-directory and raw-disk environments. qcow2 has a built-in COW layer; raw does not. That single difference determines how you take a snapshot, what rollback actually does, and how you reclaim capacity.
External references: Proxmox Snapshot Documentation, QEMU qcow2 Format Specification, btrfs Snapshot Mechanism.
First: Determine the Format
qm showconfig <vmid> | grep -E 'scsi|virtio'
# Look at the format field in the output:
# format=qcow2 -> built-in COW snapshot, use qm snapshot
# format=raw -> no built-in snapshot, check host storage layer
# /dev/sdX -> raw block device, snapshot must come from host layer
qcow2 Built-in COW Mechanism
qcow2 files contain a chain of COW layers internally. Each
qm snapshot create appends one COW mapping layer to the file header:
Write path (with snapshots):
guest writes to LBA X
-> check COW mapping: which COW layer owns LBA X?
-> write to the newest COW layer (copy-on-write)
-> read path: walk from newest COW layer backwards until data is found
Read path (with N snapshots):
at most N+1 layers to check (N COW layers + 1 base layer)
longer chain = higher random-read latency
Why it gets slower: COW layer count grows linearly, and every IO must walk the chain. A 30-layer chain has roughly 30x the random-read overhead of a 1-layer chain.
Compaction (merge): qm snapshot delete <vmid> <snapname> on a middle layer
triggers the qcow2 engine to merge that layer's data into the layer below it.
The merge is a write-heavy operation and will cause visible IO spikes. Schedule
it for a low-traffic window.
# Check current COW layer count
qm dump <vmid> | grep snapshot
# Confirm no other process has the qcow2 file open
lsof <qcow2-file-path>
# Delete old snapshots (oldest first, one at a time)
qm snapshot delete <vmid> <snapname>
Rollback: Pointer Switch, No Capacity Reclaim
qm snapshot revert <vmid> <snapname>
# Semantics: COW pointer moves to snapname
# All COW layers after snapname are logically discarded
# Physical blocks in the qcow2 file remain; file size does not change
Why capacity does not shrink: qcow2 files are either pre-allocated or sparse-grown. Rollback is a logical pointer switch, not a physical block deletion. To actually reclaim space:
# VM must be stopped
qm stop <vmid>
# Repack in place (slow on large disks, plan ahead)
qemu-img convert -f qcow2 -O qcow2 <original-file> <new-file>
# Update the disk path in qm config to point to the new file
Raw Format: No Built-in Snapshot, Two Alternative Paths
Path A: btrfs subvolume snapshot (btrfs host storage) When the raw disk lives on a btrfs mount, Proxmox's snapshot button invokes a btrfs subvolume snapshot:
# Host-side
btrfs subvolume snapshot <subvolume-containing-disk> <snapshot-subvolume>
# Proxmox UI snapshot on raw disk actually calls this underneath
btrfs snapshots are CoW and are O(1) to create (metadata only). Rollback is also
a pointer switch. Long btrfs snapshot chains have the same read-amplification
problem as qcow2. Delete with btrfs subvolume delete.
Path B: qemu-img manual base layer (no btrfs available) On ext4 or xfs hosts without btrfs or LVM, raw disks have no native snapshot support. The only option is a manual base layer:
qm stop <vmid>
# Use the current raw disk as the backing file (qcow2 required; raw does not
# support the -b backing-file flag)
qemu-img create -f qcow2 -b <raw-disk-path> <base> 1G
# Rollback = switch back to base; all writes after base are discarded
# Capacity reclaim = delete base and write back to the original raw disk
Note: the base file created with the -b flag is in qcow2 format, not
raw. Do not name it base.raw or it will mislead the next operator.
Three High-Frequency Failure Cases (based on typical production scenarios)
Case 1: 30 COW layers, P99 random-read latency jumped from 2 ms to 28 ms
A qcow2 data disk VM accumulated 30 snapshots without compaction. Application
P99 latency went from 2 ms to 28 ms. Resolution: during a low-traffic window,
delete snapshots from oldest to newest one at a time with qm snapshot delete.
Each deletion triggers an automatic merge into the layer below. Total merge time
for 30 layers was approximately 2 hours. Notify the business team about expected
latency spikes during the merge window.
Case 2: After rollback the qcow2 file is 500 GB but actual data is only 120 GB
Rolled back to a snapshot from 30 days ago. The qcow2 file is 500 GB because it
contains all 30 days of COW increments, but the logical data volume is only
120 GB. Resolution: stop the VM and run qemu-img convert -f qcow2 -O qcow2
to repack. The repacked file shrinks to approximately 130 GB. Repack time was
about 40 minutes for the 500 GB source file.
Case 3: btrfs snapshot on a raw disk on ext4, data inconsistent after rollback
Root cause: the host storage was actually an LVM volume, not btrfs. Proxmox's
snapshot button on an LVM-backed raw disk invokes an LVM snapshot, not a btrfs
subvolume snapshot. LVM snapshots have a fixed size; when the snapshot space
fills up, the snapshot silently transitions to read-only mode. Rolling back to
a read-only LVM snapshot produces data inconsistency. Confirm the underlying
storage type with lvdisplay before assuming the snapshot mechanism.
Related Articles
- Proxmox VM Cannot Reach the Network: Bridge vs NAT Triage Tree (P47)
- Proxmox VM Slowness: CPU, Memory, and Disk IO Deep Dive (P48)
- Proxmox VM Device Passthrough Hardening Checklist (P49)
- Proxmox VM Migration Pitfalls (P51)
Originality Statement
This article is fully original. The qcow2 COW mechanism and btrfs/LVM snapshot layer differences are explained for local directory and raw-disk scenarios. Decision paths and capacity reclamation procedures are drawn from the author's production environment experience and are not a rewrite of any existing article.