Skip to main content

VM Snapshots - I Love Them!


A while ago, as VirtualBox was loosing its attractiveness due to license changes, I converted my virtual machines to KVM ones managed by virt-manager. One of the features that I just love is the capability to take snapshots of the hard disks. As I do not know of an easy way to do this from the GUI, I simply use virsh which is part of the libvirt core distribution. Before trying something "dangerous", just take a snapshot. If the experiment was not successful, then it is just a simple command to undo all the latest changes. I learned to love this feature lately as I tried crazy stuff like converting a VMs hard disc from MBR to GPT partitioning and when I ended up in an unbootable system, I could simply revert to the previous snapshot. Having this feature available empowered me to try things that may break the system.

This short blog post is just intended to show with real transcripts how this works from the command line.

Taking A Snapshot

When taking a snapshot, I advise to shut down the target VM before. Then taking a snapshot of a domain is easy to do from within virsh, but we can do it in a single call to be scripting friendly:

virsh -c qemu:///system snapshot-create win10
Domain snapshot 1697533026 erstellt

Creating the snapshot can take some time, i.e. it can be in the seconds to minutes range. It will live as long as it is not removed again later. Of course, the snapshot will consume the required space and so it is important not to keep too many snapshots around for too long. Personally I did not yet encounter a situation where I needed more than one.

Listing Snapshots

Listing snapshots is, again, an easy one liner with the help of virsh:

virsh -c qemu:///system snapshot-list win10
 Name         Erstellungs-Zeit            Status
 1697533026   2023-10-17 10:57:06 +0200   shutoff

Reverting To A Snapshot

Once you know the name of a snapshot, you can revert to it easily:

virsh -c qemu:///system snapshot-revert win10 1697533026
Domain snapshot 1697533026 reverted

Again keep in mind that this operation may take time in the seconds to minutes range.

Removing A Snapshot

If you are sure that you don't need the snapshot anymore, you can easily remove it:

virsh -c qemu:///system snapshot-delete win10 1697533026
Domain Snapshot 1697533026 gelöscht

This operation can also potentially take seconds to minutes, so don't worry if it does not return immediately.


Snapshots are easy to work with in the libvirt ecosystem. Even though my preferred GUI tool virt-manager does not offer to take snapshots, I can use a command line tool just fine.

Even if you use a different setup to run your VMs, it may be worthwhile to check how to do snapshots there. Having them available is just so reassuring before trying new things. The underlying idea is also available outside virtual machine monitors, e.g. in advanced file systems like BTRFS.


Comments powered by Disqus