Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

My goal is to have Ubuntu start and stop a headless virtualbox VM gracefully when I start and stop my host machine(Ubuntu 10.04).

I'm using a script provided by Quadir Kareemullah's page.

This is the LSB comment header from the script (I eliminted vboxnet from "Required-Start" to reduce dependencies):

### BEGIN INIT INFO
# Provides:          vboxsvc
# Required-Start:    $local_fs $remote_fs vboxdrv 
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      S 0 1 6
# Short-Description: VirtualBox Service
# Description:       VirtualBox Service to startup and shutdown Virtual Machines
### END INIT INFO

As explained by Quadir I located the 'vboxsvc' in /etc/init.d/ and executed:

$sudo update-rc.d vboxsvc

This created the links for the runlevels. For example in the runlevel 2:

$ls -l /etc/rc2.d/
...
lrwxrwxrwx 1 root root  17 2010-11-03 20:02 S20vboxdrv -> ../init.d/vboxdrv
lrwxrwxrwx 1 root root  25 2010-11-03 20:03 S20vboxweb-service -> ../init.d/vboxweb-service
lrwxrwxrwx 1 root root  17 2010-11-11 21:43 S21vboxsvc -> ../init.d/vboxsvc
...

If I start|stop the service manually:

$sudo /etc/init.d/vboxsvx start

it works as expected.

The service doesn't appear listed if I do "service --status-all", but it shows up when I use sysv-rc-conf --list.

It doesn't start automatically when I boot the computer. On the other hand, the service stops automatically when I reboot or shutdown. For some reason when the system boots the link /etc/rc2.d/S21vboxnet is not being executed or something else is happening.

I know that Upstart is the way to do things now in Ubuntu, but SysV init is still supported, right?

EDIT: I think I'm close to solving the problem. I think that the solution has to do with having my home file system encrypted. When the init process is executing the corresponding startup scripts and tries to execute "sudo -H -u myuser VBoxManage myVirtualMachine -type vrdp > /dev/null" it doesn't have access to myVirtualMachine's data(which is at an encrypted file system) because I haven't logged in as myuser yet and, therefore, my home filesystem hasn't been mounted.

share|improve this question
1  
Have you tried using the full on vboxtool vboxtool.sourceforge.net or are you just trying to get the individual script startup going? –  hbdgaf Nov 13 '10 at 16:00
    
I didn't know about vboxtool, it looks good for what I'm trying to do. Thank you! –  Chuck Nov 13 '10 at 17:44
add comment

2 Answers

up vote 1 down vote accepted

As I thought the whole problem was caused by my home partition being encrypted.

I ended up following this question to remove encryption.

My advice is that, unless you know what you are doing, don't encrypt your home partition at Ubuntu's installation. If you do, be aware that unless you have logged in, everything under your home directory will be locked to other users (including root).

share|improve this answer
add comment

Wouldn't it be better just to make a new system user to run VirtualBox than to un-encrypt your home folder?

That way you still have your protection and the VM's could start without issue.

share|improve this answer
add comment

Your Answer

 
discard

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.