I am running two VirtualBox headless VMs on an Ubuntu 12.04 host. I would like these VMs to start automatically when the system boots.
I have two crontab entries set like this (under the user which owns the VMs):
@reboot /usr/bin/vboxheadless -startvm io
@reboot /usr/bin/vboxheadless -startvm pbx
But it seems that doesn't do the trick. If I run the command directly from the terminal, the machines start up without a hitch, but I can't seem to get them to start once the system starts. I'm thinking maybe the crontab is running before the VirtualBox program/library is loaded.
How do I start these VMs automatically?
Best Answer
This is what I use. It starts the VMs on boot and saves their state on shutdown/reboot
Just save it in /etc/init.d. I named mine vbox. Run
update-rc.d <script name> defaults
and you should be good to go.