How do I start a virtual machine in background upon OSX system start?
VirtualBox comes with a series of command line tools all prefixed with VBox. The command you are looking for is
VBoxHeadless --startvm "my vm name"
You can see a short description of its options via VBoxHeadless --help
.
If you don't know the name of the virtual machine you can find out via:
VBoxManage list vms
To to run upon startup on Mac OS X you can use the Automator application.
In the Automator App, select the Run Shell Script from the list and type the script:
After saving the service, import it from System Preferences
> Users & Groups
> TheLoginUser
> Login Items
> Import the service above
.
You can create the service without any additional apps
Open Terminal,
1 Create a file by writing
touch vm.command
2. Edit the file
vi vm.command
3. Press "i" button, then enter the following lines:
VBoxHeadless --startvm vmname
(make sure you've replaced "vmname" with actual name)
4.save the file by pressing Esc button, then typing :wq
5.allow it to run:
sudo chmod +x vm.command
7.Copy the vm.command file to Application folder
8.Now you can enable it with System Preferences > Users & Groups > TheLoginUser > Login Items > Import the service above
As for me nohup
is essential:
$ nohup VBoxHeadless --startvm "xnode" > /dev/null &