Skip to content

Instantly share code, notes, and snippets.

@WaaromZoMoeilijk
Created June 17, 2016 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WaaromZoMoeilijk/9c6a0cdc9741a5baf41d57ddd18bd5c3 to your computer and use it in GitHub Desktop.
Save WaaromZoMoeilijk/9c6a0cdc9741a5baf41d57ddd18bd5c3 to your computer and use it in GitHub Desktop.
VirtualBox Setup with Autostart on boot
I wanted to post how I to setup Oracle VirtualBox with VM (Virtual Machine) Autostart, Resolved Screen Resolutions Issues, etc. This is all being done on the Ubuntu 14.04.1 Linux OS.
1. Install Oracle Virtualbox
2. Install Guest Plugins
http://askubuntu.com/questions/451805/screen-resolution-problem-with-ubuntu-14-04-and-virtualbox
If you have troubles with your VM Screen Resolution after the guest installs please read the next post down about adding Additional Drivers.
3. Setting a Static IP For each VM that requires it
Set adapter one in the VM settings to “Bridged” and setting the static IP in the OS installed
OR… http://coding4streetcred.com/blog/post/VirtualBox-Configuring-Static-IPs-for-VMs
4. Setup VM Autostart shell script on boot and Permissions
Create your script using the following terminal command sudo nano /etc/init.d/StartVMs
Include the following text in the start-up script
#!/bin/sh
### BEGIN INIT INFO
# Provides: StartVMs
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Starts all VMs
### END INIT INFO
VMUSER=userName
case "$1" in
start)
echo "Starting VM's"
# Repeat the next Line for each VM
sudo -H -b -u $VMUSER VBoxHeadless --startvm "virtualMachineName"
;;
stop)
echo "Shutting Down VM's"
# Repeat the next Line for each VM
sudo -H -b -u $VMUSER VBoxManage controlvm "virtualMachineName" savestate
;;
*)
echo "Usage: /etc/init.d/StartVMs {start|stop}"
exit 1
;;
esac
exit 0
Give the script executable permissions
sudo chmod +x /etc/init.d/StartVMs
Setup the system to run on startup
Optional: Set script to start last (99) on startup and shutdown first on (shutdown)
sudo update-rc.d StartVMs defaults 99 01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment