Short answer: on a KVM host with libvirt, virsh snapshot-create-as VM NAME creates a snapshot, virsh snapshot-list VM lists them, virsh snapshot-revert VM NAME rolls the VM back and virsh snapshot-delete VM NAME removes one. Without options the snapshot is internal and needs qcow2 disks; --disk-only makes an external snapshot in a new overlay file instead.
virsh snapshot-create-as vm1 pre-upgrade "before the dist upgrade"
virsh snapshot-list vm1
virsh snapshot-revert vm1 pre-upgrade # back to that state, later changes are lost
virsh snapshot-delete vm1 pre-upgrade # drop the snapshot, keep the current stateThis is for a KVM host you control, such as a dedicated server running libvirt. Inside a VPS you are the guest: whether the VPS itself can be snapshotted is up to the provider's platform. virsh was not run for this page; its commands follow the virsh manual, libvirt's snapshot documentation, its release notes and its source. The qemu-img part was run for real on a throwaway image with QEMU 7.2, the version in Debian 12.
Internal or external, disk-only or full system
| Kind | Command | Where the data goes | Good to know |
|---|---|---|---|
| Internal, VM running | snapshot-create-as vm1 NAME | Disk state and RAM inside the qcow2 file | The guest is paused while its memory is saved; --live exists only for external snapshots |
| Internal, VM shut off | snapshot-create-as vm1 NAME | Disk state inside the qcow2 file | Clean if the guest was shut down cleanly |
| External, disk only | snapshot-create-as vm1 NAME --disk-only --atomic | A new overlay file; the old disk becomes read-only | Crash-consistent unless you add --quiesce |
| External, full system | --memspec file=...,snapshot=external --live | Overlay files plus a memory file | Resumes like waking from hibernation |
A disk-only snapshot of a running guest is, in libvirt's words, likely to be only crash-consistent: it holds the state of the disk on a sudden power outage, so the guest may need an fsck or a journal replay after a revert. --quiesce asks the QEMU guest agent inside the VM to freeze its file systems first, and libvirt allows it only together with --disk-only; without a running agent the snapshot fails.
Internal snapshots: qcow2 only
virsh domblklist vm1 --details
qemu-img info -U /var/lib/libvirt/images/vm1.qcow2 | grep 'file format'-U lets qemu-img read the header of an image that a running VM holds open. A raw image cannot store snapshots inside itself. On our test file, qemu-img answered (the format warning lines removed):
$ qemu-img snapshot -c s1 r.img
qemu-img: Could not create snapshot 's1': -95 (Operation not supported)For a raw disk, use an external snapshot, or convert the image to qcow2 while the VM is shut off (qemu-img convert -f raw -O qcow2 vm1.img vm1.qcow2) and point the domain at the new file with virsh edit vm1, setting the driver type to qcow2.
External snapshots, and merging them back with blockcommit
virsh snapshot-create-as vm1 pre-upgrade --disk-only --atomic
virsh domblklist vm1 # vda now points at /var/lib/libvirt/images/vm1.pre-upgradelibvirt names the overlay after the disk, with the extension replaced by the snapshot name. From then on the original file is a read-only backing file and every new write lands in the overlay. --atomic makes the whole snapshot succeed or change nothing. When the upgrade is good and you want to keep its changes, the overlay has to go back into the base file.
- libvirt 9.0 and later:
virsh snapshot-delete vm1 pre-upgradehandles external snapshots too. In the 9.0 source it runs a block commit of the overlay into its backing file and removes the overlay; deleting with--childrenor--children-onlyis not supported for them. - By hand, or on older versions: commit the active overlay and pivot the disk back to the base file, then drop the snapshot record.
virsh blockcommit vm1 vda --active --pivot --verbose
virsh domblklist vm1 # vda is vm1.qcow2 again
virsh snapshot-delete vm1 pre-upgrade --metadata # forget the snapshot, keep files
rm /var/lib/libvirt/images/vm1.pre-upgrade # only after domblklist shows the base--pivot is short for --active --wait plus the switch to the base image once both are in sync. To throw the changes away instead, snapshot-revert works for external snapshots from libvirt 9.9; libvirt 9.0 stops with revert to external snapshot not supported yet. There, shut the VM down, set the disk back to the base file with virsh edit vm1, remove the overlay and run snapshot-delete --metadata.
Offline: qemu-img snapshot on a qcow2 file
Without libvirt, or for a VM that is shut off, qemu-img snapshot manages internal snapshots directly: -c creates, -l lists, -a applies (reverts) and -d deletes. We ran this on a 64 MiB test image, writing 8 MiB of data between two snapshots with qemu-io, QEMU's disk test tool:
$ qemu-img create -f qcow2 vm1.qcow2 64M
$ qemu-img snapshot -c clean vm1.qcow2
$ qemu-io -c 'write -P 0xab 0 8M' vm1.qcow2
wrote 8388608/8388608 bytes at offset 0
$ qemu-img snapshot -c after-write vm1.qcow2
$ qemu-img snapshot -l vm1.qcow2
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK ICOUNT
1 clean 0 B 2026-11-09 13:33:07 00:00:00.000 0
2 after-write 0 B 2026-11-09 13:33:07 00:00:00.000 0
$ qemu-img snapshot -a clean vm1.qcow2
$ qemu-io -c 'read -P 0 0 8M' vm1.qcow2
read 8388608/8388608 bytes at offset 0
$ qemu-img snapshot -d after-write vm1.qcow2After -a clean the first 8 MiB read back as zeros again, so the write was undone. VM SIZE is 0 B because these snapshots hold no RAM; a snapshot taken by libvirt of a running VM shows its saved memory there. qemu-img info prints the same list under Snapshot list.
The same tool shows how an external snapshot looks on disk. An overlay is a qcow2 file with a backing file, and qemu-img commit is the offline form of blockcommit:
$ qemu-img create -f qcow2 -b vm1.qcow2 -F qcow2 vm1.overlay.qcow2
$ qemu-img info --backing-chain vm1.overlay.qcow2 | grep -E '^image|^backing file:'
image: vm1.overlay.qcow2
backing file: vm1.qcow2
image: vm1.qcow2
$ qemu-img commit vm1.overlay.qcow2
Image committed.A snapshot is not a backup
An internal snapshot lives inside the very qcow2 file it protects, and an external one is useless without its base file. Both sit on the same disks of the same host, so a failed drive, a deleted image or a broken file system takes the snapshots with it. Use snapshots for quick rollbacks around an upgrade and delete them afterwards, and keep real backups on another machine; the backup guide explains the difference. To turn a snapshot into a copy you can move off the host, export it while the VM is shut off:
qemu-img convert -O qcow2 -l snapshot.name=clean vm1.qcow2 vm1-clean.qcow2On our test image, after new data had been written to vm1.qcow2, the exported file still read back as the clean state, and vm1.qcow2 kept the new data. If your VM disks are logical volumes rather than files, the snapshot happens one layer lower, with LVM snapshots. How the pieces fit together, from the kernel module to libvirt, is in the KVM software stack, and the wider picture of guests and hosts in what virtualization is.
Frequently asked
How do I create a snapshot of a KVM virtual machine?
On the host, run virsh snapshot-create-as VM NAME. With qcow2 disks that creates an internal snapshot, including the RAM if the VM is running. Add --disk-only --atomic for an external snapshot, which keeps the old disk as a read-only base and sends new writes to an overlay file.
Can I revert a KVM snapshot while the VM is running?
Yes. virsh snapshot-revert puts the VM into the state it had when the snapshot was taken: running for a full system snapshot, shut off for a disk-only one unless you add --running or --paused. Everything written since the snapshot is lost. Reverting external snapshots needs libvirt 9.9 or later.
Why does virsh say internal snapshots of a VM with pflash based firmware are not supported?
The VM boots with UEFI, and older libvirt releases cannot store its NVRAM in an internal snapshot. libvirt 9.0 refuses them entirely, 9.3 and later allow them for a shut-off VM, and 10.9 and later also for a running VM if the NVRAM file is qcow2. Shut the VM down or take an external --disk-only snapshot instead.
Is a KVM snapshot a backup?
No. An internal snapshot lives inside the same qcow2 file and an external one depends on its base file, so both are lost with the disk or the host. Use snapshots for quick rollbacks and keep backups on another machine, for example by exporting a snapshot with qemu-img convert -l snapshot.name=NAME while the VM is shut off.