How to start Virtual box machines automatically when booting?











up vote
45
down vote

favorite
29












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.










share|improve this question
























  • Possible duplicate of How do I start applications automatically on login?
    – Sergiy Kolodyazhnyy
    Mar 4 '16 at 16:45










  • @SergiyKolodyazhnyy This question is not a duplicate of that, by any means.
    – Muhammad bin Yusrat
    May 5 '17 at 8:56















up vote
45
down vote

favorite
29












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.










share|improve this question
























  • Possible duplicate of How do I start applications automatically on login?
    – Sergiy Kolodyazhnyy
    Mar 4 '16 at 16:45










  • @SergiyKolodyazhnyy This question is not a duplicate of that, by any means.
    – Muhammad bin Yusrat
    May 5 '17 at 8:56













up vote
45
down vote

favorite
29









up vote
45
down vote

favorite
29






29





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.










share|improve this question















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.







boot scripts virtualbox autostart






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '17 at 11:57









muru

134k19285485




134k19285485










asked Jan 13 '14 at 6:12









Maythux

49.9k32164214




49.9k32164214












  • Possible duplicate of How do I start applications automatically on login?
    – Sergiy Kolodyazhnyy
    Mar 4 '16 at 16:45










  • @SergiyKolodyazhnyy This question is not a duplicate of that, by any means.
    – Muhammad bin Yusrat
    May 5 '17 at 8:56


















  • Possible duplicate of How do I start applications automatically on login?
    – Sergiy Kolodyazhnyy
    Mar 4 '16 at 16:45










  • @SergiyKolodyazhnyy This question is not a duplicate of that, by any means.
    – Muhammad bin Yusrat
    May 5 '17 at 8:56
















Possible duplicate of How do I start applications automatically on login?
– Sergiy Kolodyazhnyy
Mar 4 '16 at 16:45




Possible duplicate of How do I start applications automatically on login?
– Sergiy Kolodyazhnyy
Mar 4 '16 at 16:45












@SergiyKolodyazhnyy This question is not a duplicate of that, by any means.
– Muhammad bin Yusrat
May 5 '17 at 8:56




@SergiyKolodyazhnyy This question is not a duplicate of that, by any means.
– Muhammad bin Yusrat
May 5 '17 at 8:56










13 Answers
13






active

oldest

votes

















up vote
46
down vote



accepted










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







share|improve this answer























  • how to start a particular virtual machine using startup script
    – Beginner
    Sep 26 '14 at 7:36








  • 1




    My 14.04 claims that there's no such service as 'vboxautostart-service', have you tested this?
    – Arronical
    Jun 23 '15 at 16:24










  • @Arronical The OP and the instructions from which the answer was sourced were both for Ubuntu 12.04. YMMV with versions after that.
    – kdmurray
    Jun 25 '15 at 22:36










  • It turns out that it virtualbox 4.3.10 doesn't download the init scripts on 14.04, but ndasuser's answer below helped me fix that. +1s all round!
    – Arronical
    Jun 26 '15 at 8:26










  • I was trying make this solution work on ubuntu 15.10 with no sucess.. I ended using this post freesoftwareservers.com/index.php/2015/10/24/… .. maybe not the correct approach, but it works
    – mozart_ar
    Apr 17 '16 at 1:42


















up vote
12
down vote













I had similar unhappy incidents trying this operation on the vanilla LTS.



~$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="14.04.1 LTS, Trusty Tahr"


On this version, the key file /etc/init.d/vboxautostart-service was not installed.



As far as I know all the VitualBox and requirements were put in by apt-get, so I cannot say why the 'vboxautostart-service' file was not also provided. But to get over this here are my update to kdmurray's post.



1) /etc/default/virtualbox file existed for me. So must add vars:



VBOXAUTOSTART_DB=/etc/vbox
VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg


2) Must create /etc/vbox/autostart.cfg as indicated by OP.



6b) Need to get a vboxautostart-service script and make it executable.



cd /etc/init.d/
sudo wget http://www.virtualbox.org/browser/vbox/trunk/src/VBox/Installer/linux/vboxautostart-service.sh?format=raw -O vboxautostart-service
sudo chmod +x vboxautostart-service


6c) Alert the rc.d controller, but I used 24 as the start time. Putting just 20 and it did not start up. Perhaps it ran even before virtualbox was working.



sudo update-rc.d vboxautostart-service defaults 24 24


Then rebooting launched the VM correctly.






share|improve this answer





















  • In version 5.2 you have to edit vboxautostart-service and replace vboxdrv in the # Required Start / # Required Stop lines by virtualbox. It seems that they renamed the service, so the OS cannot detect start/stop priorities correctly. I think you don't need step 6c if you replaced those lines.
    – fishbone
    Oct 5 at 4:55


















up vote
6
down vote













After many unhappy hours trying to get the procedures in from kdmurray above to work, without success I eventually found a method that worked simply.



First my Linux host (Mint 17) was set up at boot time to login automatically to my main account.



Second I used the facilities in VirtualBox GUI (v4.3.12) to create a shortcut for each Virtual Machine on the desktop. {right-click the VM in left column & select "Create Shortcut on Desktop"}



Next: I had already found that bringing up
Menu->Control Centre -> Startup Applications -> Add
and adding the desktop shortcuts gave files that did not work, I spotted from other answer on this page that the location of the startups is /home/USERNAME/.config/autostart
so I did a right-click on each of the desktop VM shortcuts and then pasted them into that folder, overwriting the earlier crap files. Now they developed the 'pretty' VirtualBox icons.



And sure enough on restarting the host computer, the 3 VMs started automagically.



:-)



Bill Williams



PS: alas I still have something missing, because often the Virtual Machines will not start up on boot, instead they generate an error dialog box which says they are locked, even if I have told them to shutdown before the host was re-booted.






share|improve this answer



















  • 1




    FYI there is no "answer 5". The number you see on the left of each answer is the total vote count. Having said that, yours is a good alternative GUI method. Thanks for the contribution.
    – hmayag
    Aug 24 '14 at 20:42


















up vote
5
down vote













You can use vboxmanage startvm "my virtual machine" --type=headless|gui|sdl (one of those). Use "headless" if they're servers that you connect to by other means than using the gui.



To actually run these commands at the right time during boot, you'll want to read up on Upstart.






share|improve this answer




























    up vote
    5
    down vote













    In addition to the good description of the vboxautostart-service above, you can do



    VBoxManage modifyvm server --autostop-type savestate


    to automatically stop the guest at shutdown. For Ubuntu 14.04 I had to add a sleep 30 to the vboxautostart-service stop section, so that it waits until guest has been saved completely.






    share|improve this answer




























      up vote
      2
      down vote













      I found a simpler way under Ubuntu 16.04 running VBox 5.1.34.



      While in VBox, right-click on the running or idle VM in the list, select 'Create Shortcut on Desktop". Once you see the icon on your desktop, open with any tool that let's you see the underlying command VBox created (on my system, I right click and select 'properties') Copy this to the clipboard.



      Open the program to update 'startup applications' and create a new application that starts at boot time, pasting in the command you copied from the desktop link created by VirtualBox.






      share|improve this answer




























        up vote
        1
        down vote













        To start a VM on logging in to our session we may want to define a .desktop file:




        • Add Virtualbox Shortcut in Unity Launcher to boot to a VM


        When this file was copied or moved to our autostart directory it will then be executed after we log in:




        • How do I start applications automatically on login?


        Running Virtual Box in user space may help to avoid unwanted side effects of starting them during boot (e.g. the VM runs as root, boot time increases incredibly, ...).






        share|improve this answer






























          up vote
          1
          down vote













          This can be done using VirtualBox Command Line Management Interface.
          Just run the following script at start up.



          #!/bin/bash
          VMUSER="vmuser"
          VMNAME="RedHatVM" #also you can put UUID in this variable (VMNAME="4ec6acc1-a232-566d-a040-6bc4aadc19a6")

          case "$1" in
          start)
          echo "===Starting VirtualBox VM==="
          sudo -H -u $VMUSER VBoxManage startvm "$VMNAME" --type headless
          ;;
          stop)
          echo "===Saving state of Virtualbox VM==="
          sudo -H -u $VMUSER VBoxManage controlvm "$VMNAME" savestate
          sleep 20
          ;;
          shutdown)
          echo "===Shutting down Virtualbox VM==="
          sudo -H -u $VMUSER VBoxManage controlvm "$VMNAME" acpipowerbutton
          sleep 20
          ;;
          reset)
          echo "===Resetting VirtualBox VM==="
          sudo -H -u $VMUSER VBoxManage controlvm "$VMNAME" reset
          ;;
          status)
          echo -n "VMNAME->";sudo -H -u $VMUSER VBoxManage showvminfo "$VMNAME" --machinereadable |grep "VMState="| cut -d "=" -f2
          ;;
          echo "Usage: /etc/init.d/VMscript {start|stop|shutdown|reset|status}"
          exit 1
          ;;
          esac

          exit 0


          There is a nice tutorial for more info.






          share|improve this answer























          • Welcome .. Please Copy / paste important info from the link
            – storm
            May 27 '16 at 19:55


















          up vote
          1
          down vote













          Addon to @kdmurray answer.



          If you get error on:



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


          To solve this, I had to manually create files "username".start and "username".stop with:



          sudo touch "username".start
          sudo touch "username".stop


          And change owner with:



          sudo chown "username" "username".start
          sudo chown "username" "username".stop


          rerun:



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


          then restart service:



          sudo service vboxautostart-service stop
          sudo service vboxautostart-service start


          check is all is ok with:



          top


          and you should see "VBox..." process in a list, if virtual machine is running






          share|improve this answer




























            up vote
            0
            down vote













            You could also get the gnome session manager described here. Gnome Session Manager
            It is in the sofware center or you could just go to a terminal and type
            sudo apt-get install gnome-session-common



            Next you can create a little script to run and use the gnome session manager to start it. Here is a little sample script to get you going...



            #!/bin/sh

            #vboxmanage startvm "my virtual machine" --type=headless|gui|sdl (one of those)
            # So if your username is user, and virtualbox put your VMs in the default location, and you want headless...

            vboxmanage startvm '/home/user/VirtualBox VMs/myvmname' --type=gui





            share|improve this answer






























              up vote
              0
              down vote













              This is how i start my Centos (name of my virtual machine) when my host machine reboots. I use crontab for that job. Here is my crontab entry:



              @reboot VBoxHeadless --startvm "Centos" &





              share|improve this answer






























                up vote
                0
                down vote













                For Ubuntu server 16.04.1 LTS I solved this by doing:





                First activate the rc-local.service



                sudo systemctl enable rc-local.service


                Add the following line in /etc/rc.local



                su virtual_box_user -c "VBoxHeadless -startvm 'virtual_machine_name' &"


                Note that the virtual_box_user is the one that can see the virtual machine (that you are willing to start) executing the command:



                VBoxManage list vms


                Example:



                $ VBoxManage list vms
                "virtualbox1" {2eb3ba3b-bcb3-4515-95d9-d33bce214c28}
                "virtualbox2" {62365634-f2q4-40c0-b4ed-22f4ab84441a}


                The modified /etc/rc.local should look like this



                #!/bin/sh -e
                #
                # rc.local
                #
                # This script is executed at the end of each multiuser runlevel.
                # Make sure that the script will "exit 0" on success or any other
                # value on error.
                #
                # In order to enable or disable this script just change the execution
                # bits.
                #
                # By default this script does nothing.

                su bob -c "VBoxManage startvm 'virtualbox1' --type headless &"
                su bob -c "VBoxManage startvm 'virtualbox2' --type headless &"

                exit 0


                If you don't choose the right owner of virtualbox, you should see the error typing the command:



                sudo systemctl status rc-local.service


                I hope this can help






                share|improve this answer






























                  up vote
                  0
                  down vote













                  1 - Create a file:



                  nano /etc/init.d/vm-start


                  Paste this:



                  #!/bin/bash
                  /bin/echo "* Starting VMS..."
                  /bin/sleep 1
                  /bin/su validuser -c "/usr/bin/vboxmanage startvm MACHINENAME--type headless"
                  /bin/sleep 1



                  • Replace "validuser" with your username

                  • Replace "MACHINENAME" with your virtual machine name

                  • If you need to start more than 1 machine, repeat the line above with your virtual machine name:


                  /bin/su validuser -c "/usr/bin/vboxmanage startvm MACHINENAME2--type headless"
                  /bin/sleep 1



                  2 - Make file vm-start executable:



                  chmod +x /etc/init.d/vm-start


                  3 - Edit rc.local



                  nano /etc/rc.local


                  Add this:



                  #!/bin/bash
                  /etc/init.d/vm-start
                  exit 0


                  4 - Reboot.






                  share|improve this answer























                    Your Answer








                    StackExchange.ready(function() {
                    var channelOptions = {
                    tags: "".split(" "),
                    id: "89"
                    };
                    initTagRenderer("".split(" "), "".split(" "), channelOptions);

                    StackExchange.using("externalEditor", function() {
                    // Have to fire editor after snippets, if snippets enabled
                    if (StackExchange.settings.snippets.snippetsEnabled) {
                    StackExchange.using("snippets", function() {
                    createEditor();
                    });
                    }
                    else {
                    createEditor();
                    }
                    });

                    function createEditor() {
                    StackExchange.prepareEditor({
                    heartbeatType: 'answer',
                    convertImagesToLinks: true,
                    noModals: true,
                    showLowRepImageUploadWarning: true,
                    reputationToPostImages: 10,
                    bindNavPrevention: true,
                    postfix: "",
                    imageUploader: {
                    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                    allowUrls: true
                    },
                    onDemand: true,
                    discardSelector: ".discard-answer"
                    ,immediatelyShowMarkdownHelp:true
                    });


                    }
                    });














                    draft saved

                    draft discarded


















                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f404665%2fhow-to-start-virtual-box-machines-automatically-when-booting%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown

























                    13 Answers
                    13






                    active

                    oldest

                    votes








                    13 Answers
                    13






                    active

                    oldest

                    votes









                    active

                    oldest

                    votes






                    active

                    oldest

                    votes








                    up vote
                    46
                    down vote



                    accepted










                    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







                    share|improve this answer























                    • how to start a particular virtual machine using startup script
                      – Beginner
                      Sep 26 '14 at 7:36








                    • 1




                      My 14.04 claims that there's no such service as 'vboxautostart-service', have you tested this?
                      – Arronical
                      Jun 23 '15 at 16:24










                    • @Arronical The OP and the instructions from which the answer was sourced were both for Ubuntu 12.04. YMMV with versions after that.
                      – kdmurray
                      Jun 25 '15 at 22:36










                    • It turns out that it virtualbox 4.3.10 doesn't download the init scripts on 14.04, but ndasuser's answer below helped me fix that. +1s all round!
                      – Arronical
                      Jun 26 '15 at 8:26










                    • I was trying make this solution work on ubuntu 15.10 with no sucess.. I ended using this post freesoftwareservers.com/index.php/2015/10/24/… .. maybe not the correct approach, but it works
                      – mozart_ar
                      Apr 17 '16 at 1:42















                    up vote
                    46
                    down vote



                    accepted










                    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







                    share|improve this answer























                    • how to start a particular virtual machine using startup script
                      – Beginner
                      Sep 26 '14 at 7:36








                    • 1




                      My 14.04 claims that there's no such service as 'vboxautostart-service', have you tested this?
                      – Arronical
                      Jun 23 '15 at 16:24










                    • @Arronical The OP and the instructions from which the answer was sourced were both for Ubuntu 12.04. YMMV with versions after that.
                      – kdmurray
                      Jun 25 '15 at 22:36










                    • It turns out that it virtualbox 4.3.10 doesn't download the init scripts on 14.04, but ndasuser's answer below helped me fix that. +1s all round!
                      – Arronical
                      Jun 26 '15 at 8:26










                    • I was trying make this solution work on ubuntu 15.10 with no sucess.. I ended using this post freesoftwareservers.com/index.php/2015/10/24/… .. maybe not the correct approach, but it works
                      – mozart_ar
                      Apr 17 '16 at 1:42













                    up vote
                    46
                    down vote



                    accepted







                    up vote
                    46
                    down vote



                    accepted






                    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







                    share|improve this answer














                    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








                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited May 3 '17 at 20:06

























                    answered Jan 13 '14 at 7:27









                    kdmurray

                    58446




                    58446












                    • how to start a particular virtual machine using startup script
                      – Beginner
                      Sep 26 '14 at 7:36








                    • 1




                      My 14.04 claims that there's no such service as 'vboxautostart-service', have you tested this?
                      – Arronical
                      Jun 23 '15 at 16:24










                    • @Arronical The OP and the instructions from which the answer was sourced were both for Ubuntu 12.04. YMMV with versions after that.
                      – kdmurray
                      Jun 25 '15 at 22:36










                    • It turns out that it virtualbox 4.3.10 doesn't download the init scripts on 14.04, but ndasuser's answer below helped me fix that. +1s all round!
                      – Arronical
                      Jun 26 '15 at 8:26










                    • I was trying make this solution work on ubuntu 15.10 with no sucess.. I ended using this post freesoftwareservers.com/index.php/2015/10/24/… .. maybe not the correct approach, but it works
                      – mozart_ar
                      Apr 17 '16 at 1:42


















                    • how to start a particular virtual machine using startup script
                      – Beginner
                      Sep 26 '14 at 7:36








                    • 1




                      My 14.04 claims that there's no such service as 'vboxautostart-service', have you tested this?
                      – Arronical
                      Jun 23 '15 at 16:24










                    • @Arronical The OP and the instructions from which the answer was sourced were both for Ubuntu 12.04. YMMV with versions after that.
                      – kdmurray
                      Jun 25 '15 at 22:36










                    • It turns out that it virtualbox 4.3.10 doesn't download the init scripts on 14.04, but ndasuser's answer below helped me fix that. +1s all round!
                      – Arronical
                      Jun 26 '15 at 8:26










                    • I was trying make this solution work on ubuntu 15.10 with no sucess.. I ended using this post freesoftwareservers.com/index.php/2015/10/24/… .. maybe not the correct approach, but it works
                      – mozart_ar
                      Apr 17 '16 at 1:42
















                    how to start a particular virtual machine using startup script
                    – Beginner
                    Sep 26 '14 at 7:36






                    how to start a particular virtual machine using startup script
                    – Beginner
                    Sep 26 '14 at 7:36






                    1




                    1




                    My 14.04 claims that there's no such service as 'vboxautostart-service', have you tested this?
                    – Arronical
                    Jun 23 '15 at 16:24




                    My 14.04 claims that there's no such service as 'vboxautostart-service', have you tested this?
                    – Arronical
                    Jun 23 '15 at 16:24












                    @Arronical The OP and the instructions from which the answer was sourced were both for Ubuntu 12.04. YMMV with versions after that.
                    – kdmurray
                    Jun 25 '15 at 22:36




                    @Arronical The OP and the instructions from which the answer was sourced were both for Ubuntu 12.04. YMMV with versions after that.
                    – kdmurray
                    Jun 25 '15 at 22:36












                    It turns out that it virtualbox 4.3.10 doesn't download the init scripts on 14.04, but ndasuser's answer below helped me fix that. +1s all round!
                    – Arronical
                    Jun 26 '15 at 8:26




                    It turns out that it virtualbox 4.3.10 doesn't download the init scripts on 14.04, but ndasuser's answer below helped me fix that. +1s all round!
                    – Arronical
                    Jun 26 '15 at 8:26












                    I was trying make this solution work on ubuntu 15.10 with no sucess.. I ended using this post freesoftwareservers.com/index.php/2015/10/24/… .. maybe not the correct approach, but it works
                    – mozart_ar
                    Apr 17 '16 at 1:42




                    I was trying make this solution work on ubuntu 15.10 with no sucess.. I ended using this post freesoftwareservers.com/index.php/2015/10/24/… .. maybe not the correct approach, but it works
                    – mozart_ar
                    Apr 17 '16 at 1:42












                    up vote
                    12
                    down vote













                    I had similar unhappy incidents trying this operation on the vanilla LTS.



                    ~$ cat /etc/os-release 
                    NAME="Ubuntu"
                    VERSION="14.04.1 LTS, Trusty Tahr"


                    On this version, the key file /etc/init.d/vboxautostart-service was not installed.



                    As far as I know all the VitualBox and requirements were put in by apt-get, so I cannot say why the 'vboxautostart-service' file was not also provided. But to get over this here are my update to kdmurray's post.



                    1) /etc/default/virtualbox file existed for me. So must add vars:



                    VBOXAUTOSTART_DB=/etc/vbox
                    VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg


                    2) Must create /etc/vbox/autostart.cfg as indicated by OP.



                    6b) Need to get a vboxautostart-service script and make it executable.



                    cd /etc/init.d/
                    sudo wget http://www.virtualbox.org/browser/vbox/trunk/src/VBox/Installer/linux/vboxautostart-service.sh?format=raw -O vboxautostart-service
                    sudo chmod +x vboxautostart-service


                    6c) Alert the rc.d controller, but I used 24 as the start time. Putting just 20 and it did not start up. Perhaps it ran even before virtualbox was working.



                    sudo update-rc.d vboxautostart-service defaults 24 24


                    Then rebooting launched the VM correctly.






                    share|improve this answer





















                    • In version 5.2 you have to edit vboxautostart-service and replace vboxdrv in the # Required Start / # Required Stop lines by virtualbox. It seems that they renamed the service, so the OS cannot detect start/stop priorities correctly. I think you don't need step 6c if you replaced those lines.
                      – fishbone
                      Oct 5 at 4:55















                    up vote
                    12
                    down vote













                    I had similar unhappy incidents trying this operation on the vanilla LTS.



                    ~$ cat /etc/os-release 
                    NAME="Ubuntu"
                    VERSION="14.04.1 LTS, Trusty Tahr"


                    On this version, the key file /etc/init.d/vboxautostart-service was not installed.



                    As far as I know all the VitualBox and requirements were put in by apt-get, so I cannot say why the 'vboxautostart-service' file was not also provided. But to get over this here are my update to kdmurray's post.



                    1) /etc/default/virtualbox file existed for me. So must add vars:



                    VBOXAUTOSTART_DB=/etc/vbox
                    VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg


                    2) Must create /etc/vbox/autostart.cfg as indicated by OP.



                    6b) Need to get a vboxautostart-service script and make it executable.



                    cd /etc/init.d/
                    sudo wget http://www.virtualbox.org/browser/vbox/trunk/src/VBox/Installer/linux/vboxautostart-service.sh?format=raw -O vboxautostart-service
                    sudo chmod +x vboxautostart-service


                    6c) Alert the rc.d controller, but I used 24 as the start time. Putting just 20 and it did not start up. Perhaps it ran even before virtualbox was working.



                    sudo update-rc.d vboxautostart-service defaults 24 24


                    Then rebooting launched the VM correctly.






                    share|improve this answer





















                    • In version 5.2 you have to edit vboxautostart-service and replace vboxdrv in the # Required Start / # Required Stop lines by virtualbox. It seems that they renamed the service, so the OS cannot detect start/stop priorities correctly. I think you don't need step 6c if you replaced those lines.
                      – fishbone
                      Oct 5 at 4:55













                    up vote
                    12
                    down vote










                    up vote
                    12
                    down vote









                    I had similar unhappy incidents trying this operation on the vanilla LTS.



                    ~$ cat /etc/os-release 
                    NAME="Ubuntu"
                    VERSION="14.04.1 LTS, Trusty Tahr"


                    On this version, the key file /etc/init.d/vboxautostart-service was not installed.



                    As far as I know all the VitualBox and requirements were put in by apt-get, so I cannot say why the 'vboxautostart-service' file was not also provided. But to get over this here are my update to kdmurray's post.



                    1) /etc/default/virtualbox file existed for me. So must add vars:



                    VBOXAUTOSTART_DB=/etc/vbox
                    VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg


                    2) Must create /etc/vbox/autostart.cfg as indicated by OP.



                    6b) Need to get a vboxautostart-service script and make it executable.



                    cd /etc/init.d/
                    sudo wget http://www.virtualbox.org/browser/vbox/trunk/src/VBox/Installer/linux/vboxautostart-service.sh?format=raw -O vboxautostart-service
                    sudo chmod +x vboxautostart-service


                    6c) Alert the rc.d controller, but I used 24 as the start time. Putting just 20 and it did not start up. Perhaps it ran even before virtualbox was working.



                    sudo update-rc.d vboxautostart-service defaults 24 24


                    Then rebooting launched the VM correctly.






                    share|improve this answer












                    I had similar unhappy incidents trying this operation on the vanilla LTS.



                    ~$ cat /etc/os-release 
                    NAME="Ubuntu"
                    VERSION="14.04.1 LTS, Trusty Tahr"


                    On this version, the key file /etc/init.d/vboxautostart-service was not installed.



                    As far as I know all the VitualBox and requirements were put in by apt-get, so I cannot say why the 'vboxautostart-service' file was not also provided. But to get over this here are my update to kdmurray's post.



                    1) /etc/default/virtualbox file existed for me. So must add vars:



                    VBOXAUTOSTART_DB=/etc/vbox
                    VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg


                    2) Must create /etc/vbox/autostart.cfg as indicated by OP.



                    6b) Need to get a vboxautostart-service script and make it executable.



                    cd /etc/init.d/
                    sudo wget http://www.virtualbox.org/browser/vbox/trunk/src/VBox/Installer/linux/vboxautostart-service.sh?format=raw -O vboxautostart-service
                    sudo chmod +x vboxautostart-service


                    6c) Alert the rc.d controller, but I used 24 as the start time. Putting just 20 and it did not start up. Perhaps it ran even before virtualbox was working.



                    sudo update-rc.d vboxautostart-service defaults 24 24


                    Then rebooting launched the VM correctly.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 11 '14 at 2:32









                    ndasusers

                    23124




                    23124












                    • In version 5.2 you have to edit vboxautostart-service and replace vboxdrv in the # Required Start / # Required Stop lines by virtualbox. It seems that they renamed the service, so the OS cannot detect start/stop priorities correctly. I think you don't need step 6c if you replaced those lines.
                      – fishbone
                      Oct 5 at 4:55


















                    • In version 5.2 you have to edit vboxautostart-service and replace vboxdrv in the # Required Start / # Required Stop lines by virtualbox. It seems that they renamed the service, so the OS cannot detect start/stop priorities correctly. I think you don't need step 6c if you replaced those lines.
                      – fishbone
                      Oct 5 at 4:55
















                    In version 5.2 you have to edit vboxautostart-service and replace vboxdrv in the # Required Start / # Required Stop lines by virtualbox. It seems that they renamed the service, so the OS cannot detect start/stop priorities correctly. I think you don't need step 6c if you replaced those lines.
                    – fishbone
                    Oct 5 at 4:55




                    In version 5.2 you have to edit vboxautostart-service and replace vboxdrv in the # Required Start / # Required Stop lines by virtualbox. It seems that they renamed the service, so the OS cannot detect start/stop priorities correctly. I think you don't need step 6c if you replaced those lines.
                    – fishbone
                    Oct 5 at 4:55










                    up vote
                    6
                    down vote













                    After many unhappy hours trying to get the procedures in from kdmurray above to work, without success I eventually found a method that worked simply.



                    First my Linux host (Mint 17) was set up at boot time to login automatically to my main account.



                    Second I used the facilities in VirtualBox GUI (v4.3.12) to create a shortcut for each Virtual Machine on the desktop. {right-click the VM in left column & select "Create Shortcut on Desktop"}



                    Next: I had already found that bringing up
                    Menu->Control Centre -> Startup Applications -> Add
                    and adding the desktop shortcuts gave files that did not work, I spotted from other answer on this page that the location of the startups is /home/USERNAME/.config/autostart
                    so I did a right-click on each of the desktop VM shortcuts and then pasted them into that folder, overwriting the earlier crap files. Now they developed the 'pretty' VirtualBox icons.



                    And sure enough on restarting the host computer, the 3 VMs started automagically.



                    :-)



                    Bill Williams



                    PS: alas I still have something missing, because often the Virtual Machines will not start up on boot, instead they generate an error dialog box which says they are locked, even if I have told them to shutdown before the host was re-booted.






                    share|improve this answer



















                    • 1




                      FYI there is no "answer 5". The number you see on the left of each answer is the total vote count. Having said that, yours is a good alternative GUI method. Thanks for the contribution.
                      – hmayag
                      Aug 24 '14 at 20:42















                    up vote
                    6
                    down vote













                    After many unhappy hours trying to get the procedures in from kdmurray above to work, without success I eventually found a method that worked simply.



                    First my Linux host (Mint 17) was set up at boot time to login automatically to my main account.



                    Second I used the facilities in VirtualBox GUI (v4.3.12) to create a shortcut for each Virtual Machine on the desktop. {right-click the VM in left column & select "Create Shortcut on Desktop"}



                    Next: I had already found that bringing up
                    Menu->Control Centre -> Startup Applications -> Add
                    and adding the desktop shortcuts gave files that did not work, I spotted from other answer on this page that the location of the startups is /home/USERNAME/.config/autostart
                    so I did a right-click on each of the desktop VM shortcuts and then pasted them into that folder, overwriting the earlier crap files. Now they developed the 'pretty' VirtualBox icons.



                    And sure enough on restarting the host computer, the 3 VMs started automagically.



                    :-)



                    Bill Williams



                    PS: alas I still have something missing, because often the Virtual Machines will not start up on boot, instead they generate an error dialog box which says they are locked, even if I have told them to shutdown before the host was re-booted.






                    share|improve this answer



















                    • 1




                      FYI there is no "answer 5". The number you see on the left of each answer is the total vote count. Having said that, yours is a good alternative GUI method. Thanks for the contribution.
                      – hmayag
                      Aug 24 '14 at 20:42













                    up vote
                    6
                    down vote










                    up vote
                    6
                    down vote









                    After many unhappy hours trying to get the procedures in from kdmurray above to work, without success I eventually found a method that worked simply.



                    First my Linux host (Mint 17) was set up at boot time to login automatically to my main account.



                    Second I used the facilities in VirtualBox GUI (v4.3.12) to create a shortcut for each Virtual Machine on the desktop. {right-click the VM in left column & select "Create Shortcut on Desktop"}



                    Next: I had already found that bringing up
                    Menu->Control Centre -> Startup Applications -> Add
                    and adding the desktop shortcuts gave files that did not work, I spotted from other answer on this page that the location of the startups is /home/USERNAME/.config/autostart
                    so I did a right-click on each of the desktop VM shortcuts and then pasted them into that folder, overwriting the earlier crap files. Now they developed the 'pretty' VirtualBox icons.



                    And sure enough on restarting the host computer, the 3 VMs started automagically.



                    :-)



                    Bill Williams



                    PS: alas I still have something missing, because often the Virtual Machines will not start up on boot, instead they generate an error dialog box which says they are locked, even if I have told them to shutdown before the host was re-booted.






                    share|improve this answer














                    After many unhappy hours trying to get the procedures in from kdmurray above to work, without success I eventually found a method that worked simply.



                    First my Linux host (Mint 17) was set up at boot time to login automatically to my main account.



                    Second I used the facilities in VirtualBox GUI (v4.3.12) to create a shortcut for each Virtual Machine on the desktop. {right-click the VM in left column & select "Create Shortcut on Desktop"}



                    Next: I had already found that bringing up
                    Menu->Control Centre -> Startup Applications -> Add
                    and adding the desktop shortcuts gave files that did not work, I spotted from other answer on this page that the location of the startups is /home/USERNAME/.config/autostart
                    so I did a right-click on each of the desktop VM shortcuts and then pasted them into that folder, overwriting the earlier crap files. Now they developed the 'pretty' VirtualBox icons.



                    And sure enough on restarting the host computer, the 3 VMs started automagically.



                    :-)



                    Bill Williams



                    PS: alas I still have something missing, because often the Virtual Machines will not start up on boot, instead they generate an error dialog box which says they are locked, even if I have told them to shutdown before the host was re-booted.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Aug 25 '14 at 21:30

























                    answered Aug 24 '14 at 18:44









                    Bill Williams

                    6112




                    6112








                    • 1




                      FYI there is no "answer 5". The number you see on the left of each answer is the total vote count. Having said that, yours is a good alternative GUI method. Thanks for the contribution.
                      – hmayag
                      Aug 24 '14 at 20:42














                    • 1




                      FYI there is no "answer 5". The number you see on the left of each answer is the total vote count. Having said that, yours is a good alternative GUI method. Thanks for the contribution.
                      – hmayag
                      Aug 24 '14 at 20:42








                    1




                    1




                    FYI there is no "answer 5". The number you see on the left of each answer is the total vote count. Having said that, yours is a good alternative GUI method. Thanks for the contribution.
                    – hmayag
                    Aug 24 '14 at 20:42




                    FYI there is no "answer 5". The number you see on the left of each answer is the total vote count. Having said that, yours is a good alternative GUI method. Thanks for the contribution.
                    – hmayag
                    Aug 24 '14 at 20:42










                    up vote
                    5
                    down vote













                    You can use vboxmanage startvm "my virtual machine" --type=headless|gui|sdl (one of those). Use "headless" if they're servers that you connect to by other means than using the gui.



                    To actually run these commands at the right time during boot, you'll want to read up on Upstart.






                    share|improve this answer

























                      up vote
                      5
                      down vote













                      You can use vboxmanage startvm "my virtual machine" --type=headless|gui|sdl (one of those). Use "headless" if they're servers that you connect to by other means than using the gui.



                      To actually run these commands at the right time during boot, you'll want to read up on Upstart.






                      share|improve this answer























                        up vote
                        5
                        down vote










                        up vote
                        5
                        down vote









                        You can use vboxmanage startvm "my virtual machine" --type=headless|gui|sdl (one of those). Use "headless" if they're servers that you connect to by other means than using the gui.



                        To actually run these commands at the right time during boot, you'll want to read up on Upstart.






                        share|improve this answer












                        You can use vboxmanage startvm "my virtual machine" --type=headless|gui|sdl (one of those). Use "headless" if they're servers that you connect to by other means than using the gui.



                        To actually run these commands at the right time during boot, you'll want to read up on Upstart.







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Jan 13 '14 at 7:19









                        Jo-Erlend Schinstad

                        26.3k555108




                        26.3k555108






















                            up vote
                            5
                            down vote













                            In addition to the good description of the vboxautostart-service above, you can do



                            VBoxManage modifyvm server --autostop-type savestate


                            to automatically stop the guest at shutdown. For Ubuntu 14.04 I had to add a sleep 30 to the vboxautostart-service stop section, so that it waits until guest has been saved completely.






                            share|improve this answer

























                              up vote
                              5
                              down vote













                              In addition to the good description of the vboxautostart-service above, you can do



                              VBoxManage modifyvm server --autostop-type savestate


                              to automatically stop the guest at shutdown. For Ubuntu 14.04 I had to add a sleep 30 to the vboxautostart-service stop section, so that it waits until guest has been saved completely.






                              share|improve this answer























                                up vote
                                5
                                down vote










                                up vote
                                5
                                down vote









                                In addition to the good description of the vboxautostart-service above, you can do



                                VBoxManage modifyvm server --autostop-type savestate


                                to automatically stop the guest at shutdown. For Ubuntu 14.04 I had to add a sleep 30 to the vboxautostart-service stop section, so that it waits until guest has been saved completely.






                                share|improve this answer












                                In addition to the good description of the vboxautostart-service above, you can do



                                VBoxManage modifyvm server --autostop-type savestate


                                to automatically stop the guest at shutdown. For Ubuntu 14.04 I had to add a sleep 30 to the vboxautostart-service stop section, so that it waits until guest has been saved completely.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered May 12 '15 at 17:36









                                Michael Schlueter

                                10828




                                10828






















                                    up vote
                                    2
                                    down vote













                                    I found a simpler way under Ubuntu 16.04 running VBox 5.1.34.



                                    While in VBox, right-click on the running or idle VM in the list, select 'Create Shortcut on Desktop". Once you see the icon on your desktop, open with any tool that let's you see the underlying command VBox created (on my system, I right click and select 'properties') Copy this to the clipboard.



                                    Open the program to update 'startup applications' and create a new application that starts at boot time, pasting in the command you copied from the desktop link created by VirtualBox.






                                    share|improve this answer

























                                      up vote
                                      2
                                      down vote













                                      I found a simpler way under Ubuntu 16.04 running VBox 5.1.34.



                                      While in VBox, right-click on the running or idle VM in the list, select 'Create Shortcut on Desktop". Once you see the icon on your desktop, open with any tool that let's you see the underlying command VBox created (on my system, I right click and select 'properties') Copy this to the clipboard.



                                      Open the program to update 'startup applications' and create a new application that starts at boot time, pasting in the command you copied from the desktop link created by VirtualBox.






                                      share|improve this answer























                                        up vote
                                        2
                                        down vote










                                        up vote
                                        2
                                        down vote









                                        I found a simpler way under Ubuntu 16.04 running VBox 5.1.34.



                                        While in VBox, right-click on the running or idle VM in the list, select 'Create Shortcut on Desktop". Once you see the icon on your desktop, open with any tool that let's you see the underlying command VBox created (on my system, I right click and select 'properties') Copy this to the clipboard.



                                        Open the program to update 'startup applications' and create a new application that starts at boot time, pasting in the command you copied from the desktop link created by VirtualBox.






                                        share|improve this answer












                                        I found a simpler way under Ubuntu 16.04 running VBox 5.1.34.



                                        While in VBox, right-click on the running or idle VM in the list, select 'Create Shortcut on Desktop". Once you see the icon on your desktop, open with any tool that let's you see the underlying command VBox created (on my system, I right click and select 'properties') Copy this to the clipboard.



                                        Open the program to update 'startup applications' and create a new application that starts at boot time, pasting in the command you copied from the desktop link created by VirtualBox.







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Apr 10 at 20:17









                                        Dave Nagy

                                        313




                                        313






















                                            up vote
                                            1
                                            down vote













                                            To start a VM on logging in to our session we may want to define a .desktop file:




                                            • Add Virtualbox Shortcut in Unity Launcher to boot to a VM


                                            When this file was copied or moved to our autostart directory it will then be executed after we log in:




                                            • How do I start applications automatically on login?


                                            Running Virtual Box in user space may help to avoid unwanted side effects of starting them during boot (e.g. the VM runs as root, boot time increases incredibly, ...).






                                            share|improve this answer



























                                              up vote
                                              1
                                              down vote













                                              To start a VM on logging in to our session we may want to define a .desktop file:




                                              • Add Virtualbox Shortcut in Unity Launcher to boot to a VM


                                              When this file was copied or moved to our autostart directory it will then be executed after we log in:




                                              • How do I start applications automatically on login?


                                              Running Virtual Box in user space may help to avoid unwanted side effects of starting them during boot (e.g. the VM runs as root, boot time increases incredibly, ...).






                                              share|improve this answer

























                                                up vote
                                                1
                                                down vote










                                                up vote
                                                1
                                                down vote









                                                To start a VM on logging in to our session we may want to define a .desktop file:




                                                • Add Virtualbox Shortcut in Unity Launcher to boot to a VM


                                                When this file was copied or moved to our autostart directory it will then be executed after we log in:




                                                • How do I start applications automatically on login?


                                                Running Virtual Box in user space may help to avoid unwanted side effects of starting them during boot (e.g. the VM runs as root, boot time increases incredibly, ...).






                                                share|improve this answer














                                                To start a VM on logging in to our session we may want to define a .desktop file:




                                                • Add Virtualbox Shortcut in Unity Launcher to boot to a VM


                                                When this file was copied or moved to our autostart directory it will then be executed after we log in:




                                                • How do I start applications automatically on login?


                                                Running Virtual Box in user space may help to avoid unwanted side effects of starting them during boot (e.g. the VM runs as root, boot time increases incredibly, ...).







                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited Apr 13 '17 at 12:23









                                                Community

                                                1




                                                1










                                                answered Jan 13 '14 at 9:23









                                                Takkat

                                                105k35245374




                                                105k35245374






















                                                    up vote
                                                    1
                                                    down vote













                                                    This can be done using VirtualBox Command Line Management Interface.
                                                    Just run the following script at start up.



                                                    #!/bin/bash
                                                    VMUSER="vmuser"
                                                    VMNAME="RedHatVM" #also you can put UUID in this variable (VMNAME="4ec6acc1-a232-566d-a040-6bc4aadc19a6")

                                                    case "$1" in
                                                    start)
                                                    echo "===Starting VirtualBox VM==="
                                                    sudo -H -u $VMUSER VBoxManage startvm "$VMNAME" --type headless
                                                    ;;
                                                    stop)
                                                    echo "===Saving state of Virtualbox VM==="
                                                    sudo -H -u $VMUSER VBoxManage controlvm "$VMNAME" savestate
                                                    sleep 20
                                                    ;;
                                                    shutdown)
                                                    echo "===Shutting down Virtualbox VM==="
                                                    sudo -H -u $VMUSER VBoxManage controlvm "$VMNAME" acpipowerbutton
                                                    sleep 20
                                                    ;;
                                                    reset)
                                                    echo "===Resetting VirtualBox VM==="
                                                    sudo -H -u $VMUSER VBoxManage controlvm "$VMNAME" reset
                                                    ;;
                                                    status)
                                                    echo -n "VMNAME->";sudo -H -u $VMUSER VBoxManage showvminfo "$VMNAME" --machinereadable |grep "VMState="| cut -d "=" -f2
                                                    ;;
                                                    echo "Usage: /etc/init.d/VMscript {start|stop|shutdown|reset|status}"
                                                    exit 1
                                                    ;;
                                                    esac

                                                    exit 0


                                                    There is a nice tutorial for more info.






                                                    share|improve this answer























                                                    • Welcome .. Please Copy / paste important info from the link
                                                      – storm
                                                      May 27 '16 at 19:55















                                                    up vote
                                                    1
                                                    down vote













                                                    This can be done using VirtualBox Command Line Management Interface.
                                                    Just run the following script at start up.



                                                    #!/bin/bash
                                                    VMUSER="vmuser"
                                                    VMNAME="RedHatVM" #also you can put UUID in this variable (VMNAME="4ec6acc1-a232-566d-a040-6bc4aadc19a6")

                                                    case "$1" in
                                                    start)
                                                    echo "===Starting VirtualBox VM==="
                                                    sudo -H -u $VMUSER VBoxManage startvm "$VMNAME" --type headless
                                                    ;;
                                                    stop)
                                                    echo "===Saving state of Virtualbox VM==="
                                                    sudo -H -u $VMUSER VBoxManage controlvm "$VMNAME" savestate
                                                    sleep 20
                                                    ;;
                                                    shutdown)
                                                    echo "===Shutting down Virtualbox VM==="
                                                    sudo -H -u $VMUSER VBoxManage controlvm "$VMNAME" acpipowerbutton
                                                    sleep 20
                                                    ;;
                                                    reset)
                                                    echo "===Resetting VirtualBox VM==="
                                                    sudo -H -u $VMUSER VBoxManage controlvm "$VMNAME" reset
                                                    ;;
                                                    status)
                                                    echo -n "VMNAME->";sudo -H -u $VMUSER VBoxManage showvminfo "$VMNAME" --machinereadable |grep "VMState="| cut -d "=" -f2
                                                    ;;
                                                    echo "Usage: /etc/init.d/VMscript {start|stop|shutdown|reset|status}"
                                                    exit 1
                                                    ;;
                                                    esac

                                                    exit 0


                                                    There is a nice tutorial for more info.






                                                    share|improve this answer























                                                    • Welcome .. Please Copy / paste important info from the link
                                                      – storm
                                                      May 27 '16 at 19:55













                                                    up vote
                                                    1
                                                    down vote










                                                    up vote
                                                    1
                                                    down vote









                                                    This can be done using VirtualBox Command Line Management Interface.
                                                    Just run the following script at start up.



                                                    #!/bin/bash
                                                    VMUSER="vmuser"
                                                    VMNAME="RedHatVM" #also you can put UUID in this variable (VMNAME="4ec6acc1-a232-566d-a040-6bc4aadc19a6")

                                                    case "$1" in
                                                    start)
                                                    echo "===Starting VirtualBox VM==="
                                                    sudo -H -u $VMUSER VBoxManage startvm "$VMNAME" --type headless
                                                    ;;
                                                    stop)
                                                    echo "===Saving state of Virtualbox VM==="
                                                    sudo -H -u $VMUSER VBoxManage controlvm "$VMNAME" savestate
                                                    sleep 20
                                                    ;;
                                                    shutdown)
                                                    echo "===Shutting down Virtualbox VM==="
                                                    sudo -H -u $VMUSER VBoxManage controlvm "$VMNAME" acpipowerbutton
                                                    sleep 20
                                                    ;;
                                                    reset)
                                                    echo "===Resetting VirtualBox VM==="
                                                    sudo -H -u $VMUSER VBoxManage controlvm "$VMNAME" reset
                                                    ;;
                                                    status)
                                                    echo -n "VMNAME->";sudo -H -u $VMUSER VBoxManage showvminfo "$VMNAME" --machinereadable |grep "VMState="| cut -d "=" -f2
                                                    ;;
                                                    echo "Usage: /etc/init.d/VMscript {start|stop|shutdown|reset|status}"
                                                    exit 1
                                                    ;;
                                                    esac

                                                    exit 0


                                                    There is a nice tutorial for more info.






                                                    share|improve this answer














                                                    This can be done using VirtualBox Command Line Management Interface.
                                                    Just run the following script at start up.



                                                    #!/bin/bash
                                                    VMUSER="vmuser"
                                                    VMNAME="RedHatVM" #also you can put UUID in this variable (VMNAME="4ec6acc1-a232-566d-a040-6bc4aadc19a6")

                                                    case "$1" in
                                                    start)
                                                    echo "===Starting VirtualBox VM==="
                                                    sudo -H -u $VMUSER VBoxManage startvm "$VMNAME" --type headless
                                                    ;;
                                                    stop)
                                                    echo "===Saving state of Virtualbox VM==="
                                                    sudo -H -u $VMUSER VBoxManage controlvm "$VMNAME" savestate
                                                    sleep 20
                                                    ;;
                                                    shutdown)
                                                    echo "===Shutting down Virtualbox VM==="
                                                    sudo -H -u $VMUSER VBoxManage controlvm "$VMNAME" acpipowerbutton
                                                    sleep 20
                                                    ;;
                                                    reset)
                                                    echo "===Resetting VirtualBox VM==="
                                                    sudo -H -u $VMUSER VBoxManage controlvm "$VMNAME" reset
                                                    ;;
                                                    status)
                                                    echo -n "VMNAME->";sudo -H -u $VMUSER VBoxManage showvminfo "$VMNAME" --machinereadable |grep "VMState="| cut -d "=" -f2
                                                    ;;
                                                    echo "Usage: /etc/init.d/VMscript {start|stop|shutdown|reset|status}"
                                                    exit 1
                                                    ;;
                                                    esac

                                                    exit 0


                                                    There is a nice tutorial for more info.







                                                    share|improve this answer














                                                    share|improve this answer



                                                    share|improve this answer








                                                    edited May 28 '16 at 7:45









                                                    muru

                                                    134k19285485




                                                    134k19285485










                                                    answered May 27 '16 at 18:52









                                                    Artex

                                                    1235




                                                    1235












                                                    • Welcome .. Please Copy / paste important info from the link
                                                      – storm
                                                      May 27 '16 at 19:55


















                                                    • Welcome .. Please Copy / paste important info from the link
                                                      – storm
                                                      May 27 '16 at 19:55
















                                                    Welcome .. Please Copy / paste important info from the link
                                                    – storm
                                                    May 27 '16 at 19:55




                                                    Welcome .. Please Copy / paste important info from the link
                                                    – storm
                                                    May 27 '16 at 19:55










                                                    up vote
                                                    1
                                                    down vote













                                                    Addon to @kdmurray answer.



                                                    If you get error on:



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


                                                    To solve this, I had to manually create files "username".start and "username".stop with:



                                                    sudo touch "username".start
                                                    sudo touch "username".stop


                                                    And change owner with:



                                                    sudo chown "username" "username".start
                                                    sudo chown "username" "username".stop


                                                    rerun:



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


                                                    then restart service:



                                                    sudo service vboxautostart-service stop
                                                    sudo service vboxautostart-service start


                                                    check is all is ok with:



                                                    top


                                                    and you should see "VBox..." process in a list, if virtual machine is running






                                                    share|improve this answer

























                                                      up vote
                                                      1
                                                      down vote













                                                      Addon to @kdmurray answer.



                                                      If you get error on:



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


                                                      To solve this, I had to manually create files "username".start and "username".stop with:



                                                      sudo touch "username".start
                                                      sudo touch "username".stop


                                                      And change owner with:



                                                      sudo chown "username" "username".start
                                                      sudo chown "username" "username".stop


                                                      rerun:



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


                                                      then restart service:



                                                      sudo service vboxautostart-service stop
                                                      sudo service vboxautostart-service start


                                                      check is all is ok with:



                                                      top


                                                      and you should see "VBox..." process in a list, if virtual machine is running






                                                      share|improve this answer























                                                        up vote
                                                        1
                                                        down vote










                                                        up vote
                                                        1
                                                        down vote









                                                        Addon to @kdmurray answer.



                                                        If you get error on:



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


                                                        To solve this, I had to manually create files "username".start and "username".stop with:



                                                        sudo touch "username".start
                                                        sudo touch "username".stop


                                                        And change owner with:



                                                        sudo chown "username" "username".start
                                                        sudo chown "username" "username".stop


                                                        rerun:



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


                                                        then restart service:



                                                        sudo service vboxautostart-service stop
                                                        sudo service vboxautostart-service start


                                                        check is all is ok with:



                                                        top


                                                        and you should see "VBox..." process in a list, if virtual machine is running






                                                        share|improve this answer












                                                        Addon to @kdmurray answer.



                                                        If you get error on:



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


                                                        To solve this, I had to manually create files "username".start and "username".stop with:



                                                        sudo touch "username".start
                                                        sudo touch "username".stop


                                                        And change owner with:



                                                        sudo chown "username" "username".start
                                                        sudo chown "username" "username".stop


                                                        rerun:



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


                                                        then restart service:



                                                        sudo service vboxautostart-service stop
                                                        sudo service vboxautostart-service start


                                                        check is all is ok with:



                                                        top


                                                        and you should see "VBox..." process in a list, if virtual machine is running







                                                        share|improve this answer












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered Jul 26 '16 at 9:52









                                                        Solata

                                                        1112




                                                        1112






















                                                            up vote
                                                            0
                                                            down vote













                                                            You could also get the gnome session manager described here. Gnome Session Manager
                                                            It is in the sofware center or you could just go to a terminal and type
                                                            sudo apt-get install gnome-session-common



                                                            Next you can create a little script to run and use the gnome session manager to start it. Here is a little sample script to get you going...



                                                            #!/bin/sh

                                                            #vboxmanage startvm "my virtual machine" --type=headless|gui|sdl (one of those)
                                                            # So if your username is user, and virtualbox put your VMs in the default location, and you want headless...

                                                            vboxmanage startvm '/home/user/VirtualBox VMs/myvmname' --type=gui





                                                            share|improve this answer



























                                                              up vote
                                                              0
                                                              down vote













                                                              You could also get the gnome session manager described here. Gnome Session Manager
                                                              It is in the sofware center or you could just go to a terminal and type
                                                              sudo apt-get install gnome-session-common



                                                              Next you can create a little script to run and use the gnome session manager to start it. Here is a little sample script to get you going...



                                                              #!/bin/sh

                                                              #vboxmanage startvm "my virtual machine" --type=headless|gui|sdl (one of those)
                                                              # So if your username is user, and virtualbox put your VMs in the default location, and you want headless...

                                                              vboxmanage startvm '/home/user/VirtualBox VMs/myvmname' --type=gui





                                                              share|improve this answer

























                                                                up vote
                                                                0
                                                                down vote










                                                                up vote
                                                                0
                                                                down vote









                                                                You could also get the gnome session manager described here. Gnome Session Manager
                                                                It is in the sofware center or you could just go to a terminal and type
                                                                sudo apt-get install gnome-session-common



                                                                Next you can create a little script to run and use the gnome session manager to start it. Here is a little sample script to get you going...



                                                                #!/bin/sh

                                                                #vboxmanage startvm "my virtual machine" --type=headless|gui|sdl (one of those)
                                                                # So if your username is user, and virtualbox put your VMs in the default location, and you want headless...

                                                                vboxmanage startvm '/home/user/VirtualBox VMs/myvmname' --type=gui





                                                                share|improve this answer














                                                                You could also get the gnome session manager described here. Gnome Session Manager
                                                                It is in the sofware center or you could just go to a terminal and type
                                                                sudo apt-get install gnome-session-common



                                                                Next you can create a little script to run and use the gnome session manager to start it. Here is a little sample script to get you going...



                                                                #!/bin/sh

                                                                #vboxmanage startvm "my virtual machine" --type=headless|gui|sdl (one of those)
                                                                # So if your username is user, and virtualbox put your VMs in the default location, and you want headless...

                                                                vboxmanage startvm '/home/user/VirtualBox VMs/myvmname' --type=gui






                                                                share|improve this answer














                                                                share|improve this answer



                                                                share|improve this answer








                                                                edited Jan 13 '14 at 7:55









                                                                kiri

                                                                18.7k1258103




                                                                18.7k1258103










                                                                answered Jan 13 '14 at 7:51









                                                                Scott Goodgame

                                                                2,332720




                                                                2,332720






















                                                                    up vote
                                                                    0
                                                                    down vote













                                                                    This is how i start my Centos (name of my virtual machine) when my host machine reboots. I use crontab for that job. Here is my crontab entry:



                                                                    @reboot VBoxHeadless --startvm "Centos" &





                                                                    share|improve this answer



























                                                                      up vote
                                                                      0
                                                                      down vote













                                                                      This is how i start my Centos (name of my virtual machine) when my host machine reboots. I use crontab for that job. Here is my crontab entry:



                                                                      @reboot VBoxHeadless --startvm "Centos" &





                                                                      share|improve this answer

























                                                                        up vote
                                                                        0
                                                                        down vote










                                                                        up vote
                                                                        0
                                                                        down vote









                                                                        This is how i start my Centos (name of my virtual machine) when my host machine reboots. I use crontab for that job. Here is my crontab entry:



                                                                        @reboot VBoxHeadless --startvm "Centos" &





                                                                        share|improve this answer














                                                                        This is how i start my Centos (name of my virtual machine) when my host machine reboots. I use crontab for that job. Here is my crontab entry:



                                                                        @reboot VBoxHeadless --startvm "Centos" &






                                                                        share|improve this answer














                                                                        share|improve this answer



                                                                        share|improve this answer








                                                                        edited Mar 4 '16 at 16:39









                                                                        whtyger

                                                                        4,30332135




                                                                        4,30332135










                                                                        answered Mar 4 '16 at 14:31









                                                                        user514700

                                                                        1




                                                                        1






















                                                                            up vote
                                                                            0
                                                                            down vote













                                                                            For Ubuntu server 16.04.1 LTS I solved this by doing:





                                                                            First activate the rc-local.service



                                                                            sudo systemctl enable rc-local.service


                                                                            Add the following line in /etc/rc.local



                                                                            su virtual_box_user -c "VBoxHeadless -startvm 'virtual_machine_name' &"


                                                                            Note that the virtual_box_user is the one that can see the virtual machine (that you are willing to start) executing the command:



                                                                            VBoxManage list vms


                                                                            Example:



                                                                            $ VBoxManage list vms
                                                                            "virtualbox1" {2eb3ba3b-bcb3-4515-95d9-d33bce214c28}
                                                                            "virtualbox2" {62365634-f2q4-40c0-b4ed-22f4ab84441a}


                                                                            The modified /etc/rc.local should look like this



                                                                            #!/bin/sh -e
                                                                            #
                                                                            # rc.local
                                                                            #
                                                                            # This script is executed at the end of each multiuser runlevel.
                                                                            # Make sure that the script will "exit 0" on success or any other
                                                                            # value on error.
                                                                            #
                                                                            # In order to enable or disable this script just change the execution
                                                                            # bits.
                                                                            #
                                                                            # By default this script does nothing.

                                                                            su bob -c "VBoxManage startvm 'virtualbox1' --type headless &"
                                                                            su bob -c "VBoxManage startvm 'virtualbox2' --type headless &"

                                                                            exit 0


                                                                            If you don't choose the right owner of virtualbox, you should see the error typing the command:



                                                                            sudo systemctl status rc-local.service


                                                                            I hope this can help






                                                                            share|improve this answer



























                                                                              up vote
                                                                              0
                                                                              down vote













                                                                              For Ubuntu server 16.04.1 LTS I solved this by doing:





                                                                              First activate the rc-local.service



                                                                              sudo systemctl enable rc-local.service


                                                                              Add the following line in /etc/rc.local



                                                                              su virtual_box_user -c "VBoxHeadless -startvm 'virtual_machine_name' &"


                                                                              Note that the virtual_box_user is the one that can see the virtual machine (that you are willing to start) executing the command:



                                                                              VBoxManage list vms


                                                                              Example:



                                                                              $ VBoxManage list vms
                                                                              "virtualbox1" {2eb3ba3b-bcb3-4515-95d9-d33bce214c28}
                                                                              "virtualbox2" {62365634-f2q4-40c0-b4ed-22f4ab84441a}


                                                                              The modified /etc/rc.local should look like this



                                                                              #!/bin/sh -e
                                                                              #
                                                                              # rc.local
                                                                              #
                                                                              # This script is executed at the end of each multiuser runlevel.
                                                                              # Make sure that the script will "exit 0" on success or any other
                                                                              # value on error.
                                                                              #
                                                                              # In order to enable or disable this script just change the execution
                                                                              # bits.
                                                                              #
                                                                              # By default this script does nothing.

                                                                              su bob -c "VBoxManage startvm 'virtualbox1' --type headless &"
                                                                              su bob -c "VBoxManage startvm 'virtualbox2' --type headless &"

                                                                              exit 0


                                                                              If you don't choose the right owner of virtualbox, you should see the error typing the command:



                                                                              sudo systemctl status rc-local.service


                                                                              I hope this can help






                                                                              share|improve this answer

























                                                                                up vote
                                                                                0
                                                                                down vote










                                                                                up vote
                                                                                0
                                                                                down vote









                                                                                For Ubuntu server 16.04.1 LTS I solved this by doing:





                                                                                First activate the rc-local.service



                                                                                sudo systemctl enable rc-local.service


                                                                                Add the following line in /etc/rc.local



                                                                                su virtual_box_user -c "VBoxHeadless -startvm 'virtual_machine_name' &"


                                                                                Note that the virtual_box_user is the one that can see the virtual machine (that you are willing to start) executing the command:



                                                                                VBoxManage list vms


                                                                                Example:



                                                                                $ VBoxManage list vms
                                                                                "virtualbox1" {2eb3ba3b-bcb3-4515-95d9-d33bce214c28}
                                                                                "virtualbox2" {62365634-f2q4-40c0-b4ed-22f4ab84441a}


                                                                                The modified /etc/rc.local should look like this



                                                                                #!/bin/sh -e
                                                                                #
                                                                                # rc.local
                                                                                #
                                                                                # This script is executed at the end of each multiuser runlevel.
                                                                                # Make sure that the script will "exit 0" on success or any other
                                                                                # value on error.
                                                                                #
                                                                                # In order to enable or disable this script just change the execution
                                                                                # bits.
                                                                                #
                                                                                # By default this script does nothing.

                                                                                su bob -c "VBoxManage startvm 'virtualbox1' --type headless &"
                                                                                su bob -c "VBoxManage startvm 'virtualbox2' --type headless &"

                                                                                exit 0


                                                                                If you don't choose the right owner of virtualbox, you should see the error typing the command:



                                                                                sudo systemctl status rc-local.service


                                                                                I hope this can help






                                                                                share|improve this answer














                                                                                For Ubuntu server 16.04.1 LTS I solved this by doing:





                                                                                First activate the rc-local.service



                                                                                sudo systemctl enable rc-local.service


                                                                                Add the following line in /etc/rc.local



                                                                                su virtual_box_user -c "VBoxHeadless -startvm 'virtual_machine_name' &"


                                                                                Note that the virtual_box_user is the one that can see the virtual machine (that you are willing to start) executing the command:



                                                                                VBoxManage list vms


                                                                                Example:



                                                                                $ VBoxManage list vms
                                                                                "virtualbox1" {2eb3ba3b-bcb3-4515-95d9-d33bce214c28}
                                                                                "virtualbox2" {62365634-f2q4-40c0-b4ed-22f4ab84441a}


                                                                                The modified /etc/rc.local should look like this



                                                                                #!/bin/sh -e
                                                                                #
                                                                                # rc.local
                                                                                #
                                                                                # This script is executed at the end of each multiuser runlevel.
                                                                                # Make sure that the script will "exit 0" on success or any other
                                                                                # value on error.
                                                                                #
                                                                                # In order to enable or disable this script just change the execution
                                                                                # bits.
                                                                                #
                                                                                # By default this script does nothing.

                                                                                su bob -c "VBoxManage startvm 'virtualbox1' --type headless &"
                                                                                su bob -c "VBoxManage startvm 'virtualbox2' --type headless &"

                                                                                exit 0


                                                                                If you don't choose the right owner of virtualbox, you should see the error typing the command:



                                                                                sudo systemctl status rc-local.service


                                                                                I hope this can help







                                                                                share|improve this answer














                                                                                share|improve this answer



                                                                                share|improve this answer








                                                                                edited Nov 15 '17 at 11:52









                                                                                derHugo

                                                                                2,25721428




                                                                                2,25721428










                                                                                answered Sep 14 '17 at 20:09









                                                                                Alessandro Cimbelli

                                                                                1




                                                                                1






















                                                                                    up vote
                                                                                    0
                                                                                    down vote













                                                                                    1 - Create a file:



                                                                                    nano /etc/init.d/vm-start


                                                                                    Paste this:



                                                                                    #!/bin/bash
                                                                                    /bin/echo "* Starting VMS..."
                                                                                    /bin/sleep 1
                                                                                    /bin/su validuser -c "/usr/bin/vboxmanage startvm MACHINENAME--type headless"
                                                                                    /bin/sleep 1



                                                                                    • Replace "validuser" with your username

                                                                                    • Replace "MACHINENAME" with your virtual machine name

                                                                                    • If you need to start more than 1 machine, repeat the line above with your virtual machine name:


                                                                                    /bin/su validuser -c "/usr/bin/vboxmanage startvm MACHINENAME2--type headless"
                                                                                    /bin/sleep 1



                                                                                    2 - Make file vm-start executable:



                                                                                    chmod +x /etc/init.d/vm-start


                                                                                    3 - Edit rc.local



                                                                                    nano /etc/rc.local


                                                                                    Add this:



                                                                                    #!/bin/bash
                                                                                    /etc/init.d/vm-start
                                                                                    exit 0


                                                                                    4 - Reboot.






                                                                                    share|improve this answer



























                                                                                      up vote
                                                                                      0
                                                                                      down vote













                                                                                      1 - Create a file:



                                                                                      nano /etc/init.d/vm-start


                                                                                      Paste this:



                                                                                      #!/bin/bash
                                                                                      /bin/echo "* Starting VMS..."
                                                                                      /bin/sleep 1
                                                                                      /bin/su validuser -c "/usr/bin/vboxmanage startvm MACHINENAME--type headless"
                                                                                      /bin/sleep 1



                                                                                      • Replace "validuser" with your username

                                                                                      • Replace "MACHINENAME" with your virtual machine name

                                                                                      • If you need to start more than 1 machine, repeat the line above with your virtual machine name:


                                                                                      /bin/su validuser -c "/usr/bin/vboxmanage startvm MACHINENAME2--type headless"
                                                                                      /bin/sleep 1



                                                                                      2 - Make file vm-start executable:



                                                                                      chmod +x /etc/init.d/vm-start


                                                                                      3 - Edit rc.local



                                                                                      nano /etc/rc.local


                                                                                      Add this:



                                                                                      #!/bin/bash
                                                                                      /etc/init.d/vm-start
                                                                                      exit 0


                                                                                      4 - Reboot.






                                                                                      share|improve this answer

























                                                                                        up vote
                                                                                        0
                                                                                        down vote










                                                                                        up vote
                                                                                        0
                                                                                        down vote









                                                                                        1 - Create a file:



                                                                                        nano /etc/init.d/vm-start


                                                                                        Paste this:



                                                                                        #!/bin/bash
                                                                                        /bin/echo "* Starting VMS..."
                                                                                        /bin/sleep 1
                                                                                        /bin/su validuser -c "/usr/bin/vboxmanage startvm MACHINENAME--type headless"
                                                                                        /bin/sleep 1



                                                                                        • Replace "validuser" with your username

                                                                                        • Replace "MACHINENAME" with your virtual machine name

                                                                                        • If you need to start more than 1 machine, repeat the line above with your virtual machine name:


                                                                                        /bin/su validuser -c "/usr/bin/vboxmanage startvm MACHINENAME2--type headless"
                                                                                        /bin/sleep 1



                                                                                        2 - Make file vm-start executable:



                                                                                        chmod +x /etc/init.d/vm-start


                                                                                        3 - Edit rc.local



                                                                                        nano /etc/rc.local


                                                                                        Add this:



                                                                                        #!/bin/bash
                                                                                        /etc/init.d/vm-start
                                                                                        exit 0


                                                                                        4 - Reboot.






                                                                                        share|improve this answer














                                                                                        1 - Create a file:



                                                                                        nano /etc/init.d/vm-start


                                                                                        Paste this:



                                                                                        #!/bin/bash
                                                                                        /bin/echo "* Starting VMS..."
                                                                                        /bin/sleep 1
                                                                                        /bin/su validuser -c "/usr/bin/vboxmanage startvm MACHINENAME--type headless"
                                                                                        /bin/sleep 1



                                                                                        • Replace "validuser" with your username

                                                                                        • Replace "MACHINENAME" with your virtual machine name

                                                                                        • If you need to start more than 1 machine, repeat the line above with your virtual machine name:


                                                                                        /bin/su validuser -c "/usr/bin/vboxmanage startvm MACHINENAME2--type headless"
                                                                                        /bin/sleep 1



                                                                                        2 - Make file vm-start executable:



                                                                                        chmod +x /etc/init.d/vm-start


                                                                                        3 - Edit rc.local



                                                                                        nano /etc/rc.local


                                                                                        Add this:



                                                                                        #!/bin/bash
                                                                                        /etc/init.d/vm-start
                                                                                        exit 0


                                                                                        4 - Reboot.







                                                                                        share|improve this answer














                                                                                        share|improve this answer



                                                                                        share|improve this answer








                                                                                        edited Nov 27 at 1:03

























                                                                                        answered Nov 27 at 0:55









                                                                                        Lucas Catani

                                                                                        13




                                                                                        13






























                                                                                            draft saved

                                                                                            draft discarded




















































                                                                                            Thanks for contributing an answer to Ask Ubuntu!


                                                                                            • Please be sure to answer the question. Provide details and share your research!

                                                                                            But avoid



                                                                                            • Asking for help, clarification, or responding to other answers.

                                                                                            • Making statements based on opinion; back them up with references or personal experience.


                                                                                            To learn more, see our tips on writing great answers.





                                                                                            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                                                            Please pay close attention to the following guidance:


                                                                                            • Please be sure to answer the question. Provide details and share your research!

                                                                                            But avoid



                                                                                            • Asking for help, clarification, or responding to other answers.

                                                                                            • Making statements based on opinion; back them up with references or personal experience.


                                                                                            To learn more, see our tips on writing great answers.




                                                                                            draft saved


                                                                                            draft discarded














                                                                                            StackExchange.ready(
                                                                                            function () {
                                                                                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f404665%2fhow-to-start-virtual-box-machines-automatically-when-booting%23new-answer', 'question_page');
                                                                                            }
                                                                                            );

                                                                                            Post as a guest















                                                                                            Required, but never shown





















































                                                                                            Required, but never shown














                                                                                            Required, but never shown












                                                                                            Required, but never shown







                                                                                            Required, but never shown

































                                                                                            Required, but never shown














                                                                                            Required, but never shown












                                                                                            Required, but never shown







                                                                                            Required, but never shown







                                                                                            Popular posts from this blog

                                                                                            flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                                                                                            Mangá

                                                                                             ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕