Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I installed VirtualBox v2.2.4 on a CentOS 5.2 host. I want the guest VMs to auto-start when the host boots up.

What's the correct solution? Where should I run VBoxHeadless from?

Edit: this question can be generalized to "what should I do to run something after boot in CentOS?".

Also, I'd like to have the output from VBoxHeadless (stdout/err) saved somewhere.

share|improve this question
up vote 1 down vote accepted

In answer to: 'Edit: this question can be generalized to "what should I do to run something after boot in CentOS?".'

Copy /usr/share/doc/initscripts-[your version]/sysvinitfiles to /etc/init.d/[your startup file]

Edit the file following the directions contained within. Also, look at some of the other init scripts in /etc/init.d

As sysvinitfiles suggests, it's a good idea to 'man chkconfig', but the basics are:

  1. Make sure you have something similar to # chkconfig 2345 20 80 in your script
  2. $ chmod 755 [your startup file]
  3. Run $ chkconfig --add [your startup file]
  4. service [your startup file] start|stop

Having # chkconfig 2345 tells linux to start and stop your program at bootup and shutdown respectively

share|improve this answer
Great answer, thanks! – noamtm Jul 15 '09 at 15:32

vboxtool could take care of it for you:

Easy control of virtual machines of VirtualBox (virtualization solution) on a Linux headless server. Start, stop, save, backup and show status of sessions in batch mode from command line.

Place vboxtoolinit in /etc/init.d/

chkconfig --add vboxtoolinit
chkconfig --levels 2345 vboxtoolinit on
share|improve this answer
Thanks, I'll try that. I was hoping that in the latest version there might be something built-in to do it. – noamtm Jun 18 '09 at 10:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.