How to restart VirtualBox VM to certain snapshot via Ubuntu Terminal
Problem
I need to restart my VirtualBox headless Virtual Machine and restore it to certain snapshot on every restart.
Solution
1. On Ubuntu terminal type the following commands to create a bash script as follows:
cd /user/bin
sudo nano vboxmanage-restartMyVM
2. On the nano editor type the followings:
vboxmanage controlvm "YourVMName" poweroff
vboxmanage snapshot "YourVMName" restore "YourVMSnapshotName"
vboxmanage startvm "YourVMName" -type headless
3. Press Ctrl-S to save the file and Ctrl-X to exit the editor and return to Ubuntu terminal.
4. Type the following command to allow the script to be executable
sudo chmod +x vboxmanage-restartMyVM
5. Finish.
Now everytime I type vboxmanage-restartMyVM on the Ubuntu terminal my virtual machine will be powered-off if it's on, restored to my preferred snapshot, then started. Happy day😀
Comments