How to set your VM to auto start at system startup in VirtualBox 4.2 on Ubuntu 12.04

There is a handy feature in VirtualBox 4.2 that lets you configure your VM to be automatically started every time system starts up. Below you can find the steps needed to configure your VirtualBox installation to achieve that on Ubuntu 12.04 LTS.

First, edit the default virtualbox configuration file and add the path to autostart database directory file and autostart configuration file to it.

  • nano /etc/default/virtualbox
  • Add the following entries:
    • VBOXAUTOSTART_DB=/etc/vbox

Since we have added the autostart configuration file path to virtualbox configuration file, create it and specify the virtualbox user that is allowed to start VM (mine is my-vbox-user).

  • nano /etc/vbox/vboxauto.conf
  • Add an entry for each user allowed to run autostart:
    • default_policy = deny
      my-vbox-user = {
      allow = true

In order vboxusers to write to the vbox directory, set permissions on it and also the sticky bit (make sure my-vbox-user is in the vboxusers group).

  • chgrp vboxusers /etc/vbox
  • chmod 1775 /etc/vbox

Set the path to the autostart database directory for the user allowed above (my-vbox-user).

  • VBoxManage setproperty autostartdbpath /etc/vbox

Set VirtualBox to automatically start the VM (my-VM) when system starts up and poweroff it when system halts.

  • VBoxManage modifyvm my-VM –autostart-enabled on –autostop-type poweroff
  • After executing it, you should have the following files under the directory/etc/vbox:
    • my-vbox-user.start

Restart the vboxauto service for changes to take effect.

  • service vboxautostart-service stop
    service vboxautostart-service start
This entry was posted in Linux, Virtualization and tagged , , , . Bookmark the permalink.

10 Responses to How to set your VM to auto start at system startup in VirtualBox 4.2 on Ubuntu 12.04

  1. Rolf Hauber says:

    Thanks for the good post. Unfortunately, it seems that the configuration does not apply for the new version VirtualBox 4.3.6 on Kubuntu 12.04 LTS.
    Do you have any ideas how to change the configuration in order to fit VirtualBox 4.3.6 on Kubuntu 12.04 LTS?

    Thabk you, best regard,

  2. Craig says:

    Great article. Clear and concise. Thank you

  3. Gil B. says:

    Hi Yakup,
    I tried to follow your instructions on my old Ubuntu 12.04 and all was well.
    I have just copied a VM from the old server to my new Ubuntu 13.10 server but for some reason, after setting the files (and I’ve checked several times permissions etc) and running the command: “VBoxManage modifyvm my-VM –autostart-enabled on –autostop-type poweroff” (changing the names for my own VM – I get no errors but I also get no *.start and *.stop files under /etc/vbox. This folder’s permission is 1755 with root.vboxusers ownership.
    Needless to say that the VM won’t autostart.
    Any suggestion what might be wrong? any logfiles to monitor that might point to the problem?


  4. Yakup Korkmaz says:

    Hi Gil,

    actually I haven’t tried it with the new Ubuntu 13.10 server. Maybe someone can help you on that by replying here.


  5. Wilco Jansen says:

    I have exactly the same issue, but it is working when I am logged in under the username that I am running Virtualbox, but not as root (or using sudo). This seems to be related to the fact that if you want to list an overview of VM’s as root (VBoxManage list vms) no result is returned, if you do the same as the user Virtualbox is running under, you get the VM’s…seems to be related tot this, and as such also during boot/shutdown of the system.

    Still searching for a solution…

  6. Wilco Jansen says:

    I have been debuging the start-up script and found out that the Virtualbox kernel drivers were not loaded at the time the vboxautostart-service script was fired, the message found in the log is the following: “VirtualBox kernel module not loaded!”. To make it work the startup order has to be changed, you have to do it like this:

    sudo update-rc.d -f vboxdrv remove
    sudo update-rc.d -f vboxdrv defaults 19

    This makes the kernel modules load before the init script is fired. It brings me to the next problem. This seems to work only for the first user you have setup a VM, with any other user the script does nothing. Continuing my debugging…

  7. Wilco Jansen says:

    I have created two users: “tom” and “jerry”. I have created a VM, and configured it for automatic starting. When I boot the system, only the VN’s of Jerry are automatically started, those from Tom are not.

    The following command executed manually does actually start the VM’s of Tom automatically:

    tom@system:$/etc/init.d/vboxautostart-service start

    and stopping the VM is done by

    tom@system:$/etc/init.d/vboxautostart-service stop

    But when I run the script as superuser (sudo /etc/init.d…) the script only works under Jerry, when executed as user Tom it has no effect. I am puzzled…any help is appreciated.

  8. Loyal Barber says:

    Great directions. Much better than Oracle documentation. I used this to get it working fine with Debian Wheezy.

  9. Loyal Barber says:

    Wilco Jansen,
    Did you set up autostart for the individual users: tom and jerry:

    VBoxManage setproperty autostartdbpath /etc/vbox

  10. Loyal Barber says:

    Also, run the command

    VBoxManage modifyvm my-VM –autostart-enabled on –autostop-type poweroff

    as each user who you want to autostart the virtual machine.

Leave a Reply

Your email address will not be published. Required fields are marked *