Autostart VM at boot

Discussions related to using VirtualBox on Linux hosts.

Autostart VM at boot

Postby rollingo » 17. Mar 2011, 19:27

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   Expand viewCollapse view
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   Expand viewCollapse view
nohup VBoxHeadless --startvm "XP" --vrdp=config &

and adding it to the crontab
Code: Select all   Expand viewCollapse view
@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
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

Postby Perryg » 17. Mar 2011, 19:52

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.
Perryg
Site Moderator
 
Posts: 34373
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Autostart VM at boot

Postby rollingo » 17. Mar 2011, 20:07

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   Expand viewCollapse view
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   Expand viewCollapse view
cat /home/user/vboxbootXP.sh
nohup VBoxHeadless --startvm "XP"
Last edited by rollingo on 17. Mar 2011, 20:18, edited 1 time in total.
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

Postby Perryg » 17. Mar 2011, 20:15

Is /etc/rc.local executable?
These are really Linux questions and you can actually find them all at Ubuntu
Perryg
Site Moderator
 
Posts: 34373
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX


Return to VirtualBox on Linux Hosts

Who is online

Users browsing this forum: No registered users and 16 guests