Deleting VM snapshots in VirtualBox

Oliver Schoenborn
2 min readMar 15, 2019

--

What happens if you delete a VM snapshot in VirtualBox? Turns out sometimes it’s deletion, sometimes it’s merging:

  1. If the snapshot has children, the snapshot gets merged into the children!
  2. If the snapshot does not have children or parent (i.e. a leaf snapshot that is also the root snapshot), then the snapshot state is merged into the VM!
  3. If the snapshot does not have children, and it is NOT the root snapshot, (i.e., it is a leaf snapshot with a parent snapshot), the snapshot state is lost!

So in actual fact, leaf snapshots that have a parent can only be deleted whereas all the other types of snapshots can only be merged: the merging goes to children if there are some, or to VM itself if unique snapshot (it is root, AND leaf simultaneously). Regardless of what actually happens, ie merging or deletion, the VirtualBox Manager UI calls the operation “Delete”. Beware of items 2 and 3!

Other implication is that, to go from N > 1 snapshots to only 1 specific leaf snapshot, you have to merge all snapshots into the leaf:

  1. Save a copy of the VM (with its snapshots, all UUID same and all network adapters same) via Clone — just in case you mess up the merging.
  2. Iteratively delete the root snapshot until the leaf snapshot is left

To go from N > 1 snapshot to only 1 specific NON-leaf snapshot, you have to do some deletions and some merges:

  1. Save a copy of the VM (with its snapshots, all UUID same and all network adapters same) via Clone — just in case you mess up the merging.
  2. Iteratively delete the leaf snapshot until the snapshot you want is a leaf snapshot.
  3. Iteratively delete the root snapshot until you have only the one left.
  4. Test snapshot.
  5. Discard clone.

More complicated snapshot trees will require more complicated sequences of merges and deletions.

An interesting article covering some of the above with additional details: https://raywoodcockslatest.wordpress.com/2018/02/20/virtualbox-snapshots/.

--

--