LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices



Reply
 
Search this Thread
Old 12-10-2010, 04:46 AM   #1
cabrilo
LQ Newbie
 
Registered: Nov 2004
Posts: 17

Rep: Reputation: 0
Question Virtualbox: Howto start a new machine on boot and then stop it on halt


Hello all,

As an environmentally conscious programmer, I decided to retire my old development box and virtualize it instead. So now, I have a GUEST Debian instance running in VirtualBox on top of my linux HOST. I find the setup much better - saves energy, and it's easier to back up and administer.

So, I would like to do the following: I want my GUEST to start when the host boots up. This is not an issue. I will just VBoxHeadless -startvm Debian somewhere on boot.

However, I am a bit fuzzy on how to best go about shutting the GUEST down when the HOST halts. The problem here is that the script that does this must be blocking - i.e. HOST must not halt before the GUEST does shuts down.

Now, I'm not too familiar with writing init scripts, especially upstart scripts that my distribution now uses. I suppose they are blocking, but unless I have to deal with them, I'd rather take a less manual labor approach.

How would I go about this the easiest way? Any suggestions? Any ready-made scripts?

Thanks
 
Old 12-10-2010, 01:40 PM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
My knowledge is of Slackware not ubuntu but nobody else has answered in more than 24 hours ...

VirtualBox installs a boot/shutdown script that has the VM shutdown capability you ask for. On Slackware it is rc.vboxdrv so it is probably vboxdrv within the upstart directories. rc.vboxdrv can be configured using /etc/default/virtualbox. This usage not described in the VirtualBox 3.2.8 User Manual but is mentioned in a comment in the rc.vboxdrv script. Unfortunately it does not work for me as described in this VirtualBox forum thread. It should be possible to script around this problem but it makes sense to explore the mechanism provided by VirtualBox first.
 
1 members found this post helpful.
Old 12-10-2010, 01:57 PM   #3
cabrilo
LQ Newbie
 
Registered: Nov 2004
Posts: 17

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by catkin View Post
My knowledge is of Slackware not ubuntu but nobody else has answered in more than 24 hours ...

VirtualBox installs a boot/shutdown script that has the VM shutdown capability you ask for. On Slackware it is rc.vboxdrv so it is probably vboxdrv within the upstart directories. rc.vboxdrv can be configured using /etc/default/virtualbox. This usage not described in the VirtualBox 3.2.8 User Manual but is mentioned in a comment in the rc.vboxdrv script. Unfortunately it does not work for me as described in this VirtualBox forum thread. It should be possible to script around this problem but it makes sense to explore the mechanism provided by VirtualBox first.
Thanks! That seems to be the proper way to do it.

Thanks again, very helpful.
 
Old 12-10-2010, 02:09 PM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
Quote:
Originally Posted by cabrilo View Post
Thanks! That seems to be the proper way to do it.

Thanks again, very helpful.
Well, it will be helpful if it works! Please let us know how you get on.
 
Old 12-10-2010, 02:36 PM   #5
cabrilo
LQ Newbie
 
Registered: Nov 2004
Posts: 17

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by catkin View Post
Well, it will be helpful if it works! Please let us know how you get on.
It works. However, a bit of funny business which may be related to your problem:

If there is a virtual machine running, it works perfectly fine.

However, when there are no virtual machines running, sometimes (and only sometimes!) it fails with this:

Code:
ERROR: failed to create the VirtualBox object!
ERROR: code NS_ERROR_FACTORY_NOT_REGISTERED (0x80040154) - Class not registered (extended info not available)
Most likely, the VirtualBox COM server is not running or failed to start.
Wrong owner (1000) of '/tmp/.vbox-cabrilo-ipc'.
I have no idea what exactly causes it - if I see a better pattern, I'll let you know.
 
Old 12-10-2010, 02:42 PM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
Quote:
Originally Posted by cabrilo View Post
I have no idea what exactly causes it - if I see a better pattern, I'll let you know.
Thanks for the update. Similar symptoms. AFAIK that message (actually I get many, followed by a 30 second sleep) happens when a VM has been started and shutdown before host shutdown. If a solution is not forthcoming I'll have a go at scripting a workaround.
 
1 members found this post helpful.
Old 12-14-2010, 06:20 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
Reported as a defect at http://www.virtualbox.org/ticket/7844
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HOWTO Check, Start and Stop Services GNewbie MEPIS 9 08-22-2012 11:09 PM
AWK- processing data inside start/stop pairs but ignoring start/stop lines cliffoij Programming 2 10-15-2008 07:17 AM
Mysql - Howto intall,set up,start and stop in Slackware 12. matruschka LinuxQuestions.org Member Success Stories 1 08-13-2008 03:52 AM
How can I start VirtualBox on a remote machine and log out from the terminal? crisostomo_enrico Solaris / OpenSolaris 2 08-09-2008 04:02 AM
Howto start script at boot ? hendrixx Programming 3 11-15-2005 02:42 PM


All times are GMT -5. The time now is 10:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration