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?

10
  • If you want to keep the changes you made with each snapshot start at the bottom and merge the changes. If you move your way down you will discard them
    – Ramhound
    Commented Aug 31, 2017 at 11:07
  • @Ramhound I'm confused. I've been freely creating and removing snapshots for a while and never lost current state unless I explicitly restore a snapshot :-? Commented Aug 31, 2017 at 11:32
  • In any event the amount of time it takes is going to be the same, even if the changes captured by the snapshots are saved. You are merging the changes into the base VM, the amount of changes that you made, are going to be static. So the time to merge those changes into the VM will be the same regardless, but I now that I thought about it some more, I reversed my statement. When you delete a snapshot, you are rolling your changes you made with that snapshot into the base vm, so you want the last snapshot to be merged last. You basically want the last snapshot to become the base VM right?
    – Ramhound
    Commented Aug 31, 2017 at 12:34
  • 1
    @Ramhound If I revert to "Before installing OS" I'd expect to get an empty VM and lose all my work :-? Commented Aug 31, 2017 at 12:56
  • 1
    Incidentally, suggesting a question might be a dupe isn't intended to claim that there's anything wrong with it; to the contrary, I had pretty much the same question which is why I noticed there were so many similar ones on here already. Generally its useful to note duplicates so that one question ends up acting as the "canonical" resource for future readers. Commented Jun 3, 2021 at 13:29

3 Answers 3

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

2
  • The question says “I can't clone or export the VM because it's already using 75% of the host disk.” Commented May 23, 2019 at 23:01
  • 1
    Didn't read carefully :) but technically if you specify a clone to a different HDD that has enough space it should work. You really can't clone or delete snapshots on same HDD as either approach need x2 space to really copy entire data. You could try delete one by one staring with smallest, hoping to release space for biggest but you likely end-up stuck at some point. You just need more space. Maybe move VM to other external HDD/SSD merge on other Host, move back? Commented May 24, 2019 at 18:38
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.

2
  • Do you mean this script is faster than using the GUI? Commented Mar 29 at 15:33
  • 1
    If you use the GUI, you have to delete each snapshot one at a time, and wait over 10 minutes for each snapshot to finish deletion process before being able to delete the next snapshot. It can easily take over an hour to delete 7 snapshots. Where-as if you use the script, it will delete the snapshots unattended. Commented Mar 29 at 19:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .