Automatically starting a VM when the host boots

Discussions related to using VirtualBox on Solaris hosts.
Post Reply
TheLastBoyscout
Posts: 13
Joined: 23. Jul 2011, 04:29
Primary OS: OpenSolaris 11
VBox Version: OSE other
Guest OSses: WHS 2011, OpenIndiana

Automatically starting a VM when the host boots

Post by TheLastBoyscout »

Hi,

I'm Solaris/UNIX n00b and have the following problem:
I have a headless Solaris host (OI 151) with VirtualBox 4.1.2 and like it to automatically launch a Win2008R2 VM whenever the host boots. I have not found any option in VB and I only found the VBoxManage startvm vmname command in the online manual, but that alone doesn't quite get me there. In Windows, I would just create a shortcut to the VM and move that shortcut to the startup folder (and be done with it), but how would I accomplish this on Solaris?
Is there a startup file/script that I can add the VBoxManage command to?

Thanks for your help!
TLB
TheLastBoyscout
Posts: 13
Joined: 23. Jul 2011, 04:29
Primary OS: OpenSolaris 11
VBox Version: OSE other
Guest OSses: WHS 2011, OpenIndiana

Re: Automatically starting a VM when the host boots

Post by TheLastBoyscout »

Clarification: During setup (right now), I DO have KVM (keyboard, video, mouse) connected to the Solaris system, once it is fully set up, it will no longer have KVM connected. I already created the Win2008R2 VM and its running fine. So in this case I should probably use
VBoxManage startvm "VM name" --type headless
to start the VM (as it saves resources on the Solaris host), but how do I tell Solaris to do this automatically at system boot? I didn't see any mention of this in the mentioned chapter of the manual.

TLB
TheLastBoyscout
Posts: 13
Joined: 23. Jul 2011, 04:29
Primary OS: OpenSolaris 11
VBox Version: OSE other
Guest OSses: WHS 2011, OpenIndiana

Re: Automatically starting a VM when the host boots

Post by TheLastBoyscout »

Ok, so I found this post that seems to hit the spot: Here it is: Automatically starting and stopping VBox
However, it still does not work. Here's what I did (all done as root):
  • Downloaded the attached file, unzipped it and copied it to /etc/init.d
  • Code: Select all

    chmod +x /etc/init.d/VBoxAutostart
    ln -s ../init.d/VBoxAutostart /etc/rc3.d/S98VBoxAutostart
    ln -s ../init.d/VBoxAutostart /etc/rc0.d/K00VBoxAutostart
    VBoxManage setextradata W2008R2 autostart headless
    VBoxManage setextradata W2008R2 autostop savestate
When I rebooted the system, I noticed that the VBox UI was automatically launched (why? I don't want that...) but the W2008R2 VM was still listed as powered down. Checking the VM state via "VBoxManage showvminfo W2008R2" also showed "powered off".
I then ran /etc/init.d/VBoxAutostart from the command line (as a user)
ad was greeted with:

Code: Select all

usage: VBoxAutostart start | stop
After typing in "VBoxAutostart start" the W2008R2 VM started and I got errors for the other VMs (which I don't care about at the moment).

Also, shutting down the Solaris system took only a few seconds, but it didn't seem to wait to execute the K00VBoxAutostart. Instead,when I restarted the Solaris host and I was presented the VBox UI (again, how do I prevent this?) it showed the W2008R2 VM with a red warning sign ('aborted').

Does anyone know why this didn't just work?

Thanks!
TLB
rdhalstead
Posts: 52
Joined: 26. Feb 2008, 18:58
Location: Las Vegas

Re: Automatically starting a VM when the host boots

Post by rdhalstead »

#!/bin/sh

# This script starts and stops the VirtualBox virtual machine winxpvb11.
# Use a RDP client to connect to the virtual machine.

case "$1" in

'start')
/opt/VirtualBox/VBoxHeadless --startvm "winxpvb11" &
;;

'stop') /opt/VirtualBox/VBoxManage controlvm "winxpvb11" poweroff
;;

*)
echo "Usage: $0 { start | stop }"
exit 1
;;
esac
buenger
Posts: 1
Joined: 30. Aug 2011, 22:29
Primary OS: OpenSolaris other
VBox Version: OSE other
Guest OSses: Centos

Automatically starting a VM when the host boots

Post by buenger »

Hi,

try this one http://sourceforge.net/projects/vboxsvc/

worked well for me ... after little amendments

Cheers

Chris
varboxer
Posts: 22
Joined: 29. Mar 2011, 12:29
Primary OS: Solaris
VBox Version: OSE other
Guest OSses: Solaris, Ubuntu

Re: Automatically starting a VM when the host boots

Post by varboxer »

What did you have to amend?
baekmark
Posts: 6
Joined: 31. May 2010, 10:37
Primary OS: OpenSolaris 11
VBox Version: OSE other
Guest OSses: FreeBSD, Win2003

Re: Automatically starting a VM when the host boots

Post by baekmark »

Hi there

I'm using Solaris 11 express, VBox 4.1.2 and COSvboxsvc (from this site:http://sourceforge.net/projects/vboxsvc ... 9-20100728) to stop and start my VM's. It's working right out of the box! The only change you need to make is in the file vbox-svc.xml

Install:
sudo pkgadd -d COSvboxsvc-0.11.pkg
Copy the file vbox-svc.xml to your home dir.

cp /var/svc/manifest/site/vbox-svc.xml .

Open with vi:
vi vbox-svc.xml
Search for this section:

</property_group>

<instance name='VM_NAME' enabled='false'>

<method_context working_directory='/var/tmp'>
<method_credential user='root' group='root' />
</method_context>

Change VM_NAME to the name of your vm!
And change user and group to the user that runs the virtualbox service.

Insert the service into SVC:
sudo pfexec svccfg import vbox-svc.xml

Check with svcs -a | grep "name of your VM"

Start the service with:

sudo svcadm enable "name of your VM"

That's it!

I have done this on four machines now. And they all run without problems

RGD
Post Reply