4

I have a VirtualBox VM (with Windows Server 2012 as both host and guest). I created several snapshots while configuring some difficult stuff:

Before installing OS
 \____ Before installing software A
        \____ Before installing software B
               \____ Before installing software C
                      \____ Testing this
                             \____ Testing that
                                    \____ Current state

Now everything works and I need the disk space so I want to discard all snapshots. My research suggests that there's no other way to remove snapshots than one by one, painfully slow as it is. I can't clone or export the VM because it's already using 75% of the host disk.

Should I start removing from top to bottom or viceversa? What would result in faster merges? Or it doesn't really matter?

MMM
  • 3,257

3 Answers3

2

I don't know if this is best way, but it's the fastest way, and only if you want to discard all snapshot and leave current state.

Go to snapshots, right click on current state, click clone, and select all checkboxes and set "Include all network adapter..."

enter image description here

On the next screen select "Full Clone"

On the next screen select "Current Machine State" and hit Clone

Now you have exactly same machine without any snapshots. Need to delete old machine

Cons: - need to either rename old VM before clone or new VM after clone. Since you are preserving all UUIDs all should work same including command line automation. - need additional space to make double size temporarily

Pros: - Fast Auto merge of all snapshots, so no need to waste time to delete one by one

1

From experience, I would advise that there is only one correct way to delete snapshots: From latest and move backwards, and delete one at a time.
ALWAYS IN SEQUENCE - NEVER DELETE A "MIDDLE" SNAPSHOT. Or way worse, the oldest / top level snapshot. You'd think VB would step in and keep you from making this huge error, but it happily allows it. It should just flip up a banner that says 'ha ha you'll be sorry!' after it does.
If you have never mucked anything up deleting other than the latest snapshot and sequentially moving backwards, you should be able to delete all including the oldest / top level.
If you have mucked it up, and deleted a middle snapshot, you are likely screwed as far as getting rid of everything. Usually there is a error when you try to delete and you are left with whatever snapshots that remain and you can't remove them. You would need to reload the VM at whatever beginning point (install or import).
Be sure to note that each delete process can take quite a while, near 10 minutes each snapshot or more, depending on system size.

0

Using VirtualBox version 7.0, I haven't had any problems deleting snapshots in the middle.

I needed to delete about 15 snapshots in the middle, and I used the following script to do it.

@echo off
:: Rename the following two lines to the correct VM name and executable path.
set VM_NAME="Win10ProWrk64TorrentTest"
set VBoxManageCMD="C:\Program Files\Oracle\VirtualBox\VBoxManage.exe"

for /F "tokens=* delims=" %%a in (SnapshotsList.txt) DO ( Echo Deletting snapshot %%a from VM %VM_NAME% %VBoxManageCMD% snapshot %VM_NAME% delete %%a Echo ********************************************* )

I used this script with a file called SnapshotsList.txt which stored the names of the snapshots I wanted to delete.

Example:

"qBitTorrent Installed"
"Increased Resolution"
"Updated VM software"
"After downloading MiniTool Tourent and before MiniTool install"
"Post Minitool Install and other torrent downloads"
"EaseUS Data Recovery Wizard Installed"
"EaseUS Partition Master installed"
"Removed bad DiskGenius installs"
"Removed Failed AOMEI_PartAssist"
"MiniTool Partition Wizard Installed"
"Wondershare Reparit installed"
"qTorrent option changes"
"Before removing Recoverit"

The SnapshotsList.txt file can be easily created by using the following command:

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" snapshot "MyVmNameHere" list --machinereadable >SnapshotsList.txt

Edit the file to only include the SnapshotName's that are to be deleted.

If you try this, remember to use double quotes for the snapshot names and for the VM name.

Giacomo1968
  • 58,727