Koozali.org: home of the SME Server

Autostart VirtualBox VMs?

Offline DanB35

  • ****
  • 764
  • +0/-0
    • http://www.familybrown.org
Autostart VirtualBox VMs?
« on: April 15, 2015, 02:46:23 PM »
I've installed phpVirtualBox on my SME 9 server following http://wiki.contribs.org/Phpvirtualbox, have some VMs running, and all seems to be working well.  I'd like to set things up so that two of my VMs start automatically when I boot my SME server, and stop/suspend automatically when I shut it down/reboot.  The phpVirtualBox page links to http://wiki.contribs.org/VirtualBox_4.0_on_SME_Server_v8_beta_6#Automatically_Start_Virtual_Machine for that procedure, but I note that (1) the page is geared to SME 8.0b6, while current is 9.0, and (2) it's geared to VB 4.0, while current is 4.3.something.

I also note that the first step in those instructions is to edit /etc/sysconfig/vbox, which doesn't exist on my system.  Are there more current instructions to do this?
......

Offline Stefano

  • *
  • 10,839
  • +2/-0
Re: Autostart VirtualBox VMs?
« Reply #1 on: April 15, 2015, 03:02:26 PM »
I'd start to search with google for "virtualbox autostart vm centos"..

if you find anything usefull, please feel free to update wiki, thank you

Offline DanB35

  • ****
  • 764
  • +0/-0
    • http://www.familybrown.org
Re: Autostart VirtualBox VMs?
« Reply #2 on: April 15, 2015, 03:38:35 PM »
OK, a few minutes with Google has found this page: http://lifeofageekadmin.com/how-to-set-your-virtualbox-vm-to-automatically-startup/

With a few alterations to be consistent with the installation on SME, the process looks like this:
  • Edit /etc/default/virtualbox to add VBOXAUTOSTART_DB and VBOXAUTOSTART_CONFIG
  • Create /etc/vbox/autostart.cfg giving the root user the ability to start VMs
  • Since any VMs that would be running on SME are running as root, there's no need to change the group or permissions of /etc/vbox/, nor to add groups to the root user
  • VBoxManage setproperty autostartdbpath /etc/vbox
  • Make sure VM(s) you want to autostart aren't running
  • VBoxManage modifyvm (VM name or UUID) --autostart-enabled on.  Repeat this for each VM you want to start automatically.
  • service vboxautostart-service start

I don't see that either /etc/default/virtualbox or anything in /etc/vbox/ are templated--the standard template warning header isn't on either file, and neither /etc/e-smith/templates/etc/default/ nor /etc/e-smith/templates/etc/vbox/ exist.  This process does seem to work for me--the two VMs I want to start on boot are starting.  Any red flags before I add this to the wiki for phpvirtualbox?

Edit: VBoxManage allows you to set a few other flags for the VM that may be relevant.  Two are --autostop-type (I don't see that its options are documented very well, but the value of savestate will suspend the machine) and --autostart-delay (delay in seconds before the VM is started).
« Last Edit: April 15, 2015, 03:56:34 PM by DanB35 »
......

Offline stephdl

  • *
  • 1,519
  • +0/-0
    • Linux et Geekeries
Re: Autostart VirtualBox VMs?
« Reply #3 on: April 15, 2015, 05:39:30 PM »
please dan, write all of this in the wiki, that could be useful for someone, I need also to find time there is a new version of phpvirtualbox
See http://wiki.contribs.org/Koozali_Foundation
irc : Freenode #sme_server #sme-fr

!!! Please write your knowledge to the Wiki !!!

Offline DanB35

  • ****
  • 764
  • +0/-0
    • http://www.familybrown.org
Re: Autostart VirtualBox VMs?
« Reply #4 on: April 15, 2015, 05:57:58 PM »
Done.
......

Offline stephdl

  • *
  • 1,519
  • +0/-0
    • Linux et Geekeries
Re: Autostart VirtualBox VMs?
« Reply #5 on: April 15, 2015, 06:21:35 PM »
I need also to find time there is a new version of phpvirtualbox
done
See http://wiki.contribs.org/Koozali_Foundation
irc : Freenode #sme_server #sme-fr

!!! Please write your knowledge to the Wiki !!!