Skip to content

Instantly share code, notes, and snippets.

@fuzzmz
Created August 22, 2013 14:16
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fuzzmz/6307756 to your computer and use it in GitHub Desktop.
Save fuzzmz/6307756 to your computer and use it in GitHub Desktop.
Shell script to start a headless virtualbox vm from a snapshot.
#!/bin/bash
EXPECTED_ARGS=2
if [ $# -ne $EXPECTED_ARGS ]; then
echo "Usage: $0 VMNAME_or_UUID SNAPSHOTNAME"
exit 1
fi
set -x
VBoxManage controlvm "$1" poweroff #enforce turnoff
VBoxManage snapshot "$1" restore "$2" #restore snapshot
VBoxManage showvminfo "$1" | grep State #display state to verify
VBoxHeadless -s "$1" #run in headless mode in background
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment