2

I have till now everytime saved and loaded machine from snapshot, but my SSD disk now is full and I can't do anything. Snapshots folder are using 70 GB and what I want to do now is delete all snapshots and everytime turn off machine and then turn on without snapshots. Is there any way to load last snapshot state into machine and delete all snapshots?

iWizard
  • 163

4 Answers4

2

The ability to delete all snapshots has been requested on Oracle's enhancement & bug tracker, and also in Virtualbox's forums. Sadly, AFAIK, this is still not possible to do; out-of-the-box.

There is, however, a solution!

In the form of some Python and XAML source code: VirtualBox Snapshot Deletion GUI.

You will need to compile this into an .exe file to run it. Information on how to do that can be found over at Stack Overflow: Compiling an IronPython WPF project to exe.

The author of the tool believes it would also be compatible with OS X and Linux hosts.

0

This answer works, but is a bit more crude than the GUI alternative (which 5 years later, still hasn't been ported to work on anything but Windows). This will work on BSD, Linux, Mac, but not Windows (without a Cygwin). ** Run at your own risk **

DEBUG=true; PROMPT=true

vbox_delete_all_snapshots() { 
  vboxmanage snapshot "$1" list | 
    tac |perl -lane 'print $1 if /UUID: ([a-z0-9-]+)/' |
    xargs ${PROMPT:+-p} -n1 ${DEBUG:+echo} vboxmanage snapshot "$1" delete
  if $DEBUG && [ $? = 0 ] ; then
    echo "The above commands were NOT run. Unset DEBUG (and PROMPT if you feel lucky) to do so."
  fi
}
read -p"Enter the name of the VM (or its ID): " vmname; vbox_delete_all_snapshots "$vmname"

Caveats

  • Linux will complain if there are no snapshots. If you are using Linux/GNU, you can add -r option to xargs command
  • To actually run execute the commands, do unset DEBUG . To run the commands without a prompt for each one, execute unset PROMPT.
  • This should handle a normal "tree" of snapshots, but I have only tested it on the case where each snapshot had exactly 0 or 1 children.

Sample Output

Deleting snapshot 'B5' (a02cb9e8-c5be-425d-9bcd-806d72e5a083)
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Deleting snapshot 'B4' (422b29b8-cf79-4c92-a415-a08c1d3dd5a0)
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Deleting snapshot 'B3' (c1ed469f-ffc3-4cb8-81fe-bbf6581e5858)
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Deleting snapshot 'b2' (c0fa9d90-6293-46e5-bcd7-25f2b36f95c4)
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Deleting snapshot 'B1' (894147cb-2cc0-48e3-86c7-bec156da762a)
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Deleting snapshot 'test' (44a69565-1354-4b98-a2cf-64fd7caa6c56)
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Otheus
  • 121
0

On FreeBSD i get tac: Not found, you can use tails instead

vbox_delete_all_snapshots() {
  vboxmanage snapshot "$1" list |
    tail -r |perl -lane 'print $1 if /UUID: ([a-z0-9-]+)/' |
    xargs ${PROMPT:+-p} -n1 ${DEBUG:+echo} vboxmanage snapshot "$1" delete
  if $DEBUG && [ $? = 0 ] ; then
    echo "The above commands were NOT run. Unset DEBUG (and PROMPT if you feel lucky) to do so."
  fi
}
vmname=Wayward_$USER
vbox_delete_all_snapshots "$vmname"
R de L
  • 1
0

On FreeBSD it did not work at all, on my system i create a user and with that user a Virtualbox with VBoxManage inside that user so i can see wich Virtualbox uses a lot of CPU or memory, etc....

That said, i name all my VirtualBoxes: Wayward_$USER, my script will reflect this too. This is also saver, you cannot delete all snapshots of all VirtualBoxes at once.

if [ $1 = "deletesnapshots" ] ; then
  ## Yes Delete all snapshots! This is not a Drill!
  #
  echo "Delete all the Snapshots of this machine: Wayward_$USER"
  string=$(VBoxManage snapshot "Wayward_$USER" list)

Set positional parameters to the words in the string

set -- $string

Iterate through positional parameters using a loop

remember="Leeg" for word in $@; do if [ $remember = "Name:" ] ; then echo "Remove snapshot: $word" VBoxManage snapshot Wayward_$USER delete $word fi remember=$word done else

Just showing what will be deleted without the parameter:

deletesnapshots

This is just a TEST!

echo "Keep all the snapshots, the following lines are for debugging of snapshots for: Wayward_$USER" fi

R de L
  • 1