Autostart VM at boot

Discussions related to using VirtualBox on Linux hosts.
Post Reply
rollingo
Posts: 2
Joined: 17. Mar 2011, 19:19
Primary OS: Ubuntu other
VBox Version: OSE other
Guest OSses: XP

Autostart VM at boot

Post by rollingo »

Hello, I'm running a Headless Ubuntu 10.04 Server and trying to run a VM at boot.
Tried vbooxtool without success.
vboxtool autostart works great via ssh but fails to start at boot.
Also I tried other approaches like adding in /etc/rc.local

Code: Select all

nohup exec /bin/su -c 'VBoxManage startvm --type headless XP' user >/dev/null 2>&1
And finally creating a vboxbootXP.sh file with

Code: Select all

nohup VBoxHeadless --startvm "XP" --vrdp=config &
and adding it to the crontab

Code: Select all

@reboot /home/user/vboxbootXP.sh
I'm running out of ideas, please help me with this one with an easy way to start a headless vm in ubuntu.

Many thanks in advance
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Autostart VM at boot

Post by Perryg »

Starting the guest is no problem. Create a script that has VBoxHeadless --startvm "XP" and then call it from the /etc/rc.local.
The real trick is to create a script that starts and stops the guest. If not then shutting down the host will look like you pulled the plug on the guest. Windows is especially unhappy when you do this and so is VBox. You could end up with a dead guest.

I know that such a script exists on the Ubuntu forum, but could not locate it quickly. Search the Ubuntu forums and you should find you answer.
rollingo
Posts: 2
Joined: 17. Mar 2011, 19:19
Primary OS: Ubuntu other
VBox Version: OSE other
Guest OSses: XP

Re: Autostart VM at boot

Post by rollingo »

Thanks for the assistance but even creating the script and call in it from /etc/rc.local wont work
I have no idea why this is happening, any ideas on how to check why the vboxheadless is failing to start when is booting up the server?

I know that if server is going down VM could be damaged, but at this point I don't care, just need to make this work. Here are the files.

Code: Select all

cat /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/home/user/vboxbootXP.sh &
exit 0

Code: Select all

cat /home/user/vboxbootXP.sh 
nohup VBoxHeadless --startvm "XP"
Last edited by rollingo on 17. Mar 2011, 20:18, edited 1 time in total.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Autostart VM at boot

Post by Perryg »

Is /etc/rc.local executable?
These are really Linux questions and you can actually find them all at Ubuntu
Post Reply