Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
64
rated 0 times [  64] [ 0]  / answers: 1 / hits: 244534  / 3 Years ago, mon, may 24, 2021, 7:26:43

I have many Virtual box machines in my Ubuntu12.04, each time i shutdown or reboot i have to start them one by one.



I wanna a help in writing script for automatically autostart the VBox machines when booting.


More From » boot

 Answers
0

You can use the VirtualBox Auto-start service. A good tutorial describing how to do this is posted on the "Life of a Geek Admin" blog.





The following steps are adapted from the linked blog post:




  1. First you need to create the file /etc/default/virtualbox and add a few variables.



    VBOXAUTOSTART_DB which contains an absolute path to the autostart database directory and

    VBOXAUTOSTART_CONFIG which contains the location of the autostart config settings. The file should look similar to this:



    # virtualbox defaults file
    VBOXAUTOSTART_DB=/etc/vbox
    VBOXAUTOSTART_CONFIG=/etc/vbox/vbox.cfg

  2. Now we need to create the /etc/vbox/vbox.cfg file and add



    # Default policy is to deny starting a VM, the other option is "allow".
    default_policy = deny
    # Create an entry for each user allowed to run autostart
    myuserid = {
    allow = true
    }


    Note: If the filename vbox.cfg doesn't work above, try naming it autostart.cfg.



    If you are the only user you can just add the line default_policy = allow to the vbox.cfg file.


  3. Set permissions on directory to the vboxuser group and make sure users can write to the directory as well as sticky bit.



    sudo chgrp vboxusers /etc/vbox
    sudo chmod 1775 /etc/vbox

  4. Add each of the users to the vboxusers group.



    sudo usermod -a -G vboxusers USERNAME


    (replace USERNAME with the username)




NOTE: If you have changed group permissions for the current user, log out and back in again to refresh the permissions. (credit @kR105)




  1. Every user who wants to enable autostart for individual machines has to set the path to the autostart database directory with



    VBoxManage setproperty autostartdbpath /etc/vbox


    and enable autostart for an individual VM with



    VBoxManage modifyvm <uuid|vmname> --autostart-enabled on


    This will create a myuserid.start file in /etc/vbox directory


  2. Now restart the vboxautostart-service to read in the changes.



    sudo service vboxautostart-service restart

  3. Reboot your system and your VM should start



[#27510] Tuesday, May 25, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aclavadoug

Total Points: 317
Total Questions: 103
Total Answers: 125

Location: Bangladesh
Member since Wed, Mar 24, 2021
3 Years ago
;