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

Popular posts from this blog

How to paginate SSRS Report to solve rendering performance issue on Internet Explorer

How to search Active Directory group members using Windows 10 built-in tools