Auto start Virtual Machine – Ubuntu 14.04 LTS

So if you have been following my latest guides, you probably have VirtualBox and Phpvirtualbox installed. Here is a script where you can autostart Virtual Machine on a headless server.

 

Step 1. Create your startup script.
You should create this file in etc/init.d/ and copy paste the script below to the file. Remember to change VMUSER and VMNAME so it match your Virtualbox user and the name of the virtual machine.

 

 

Step 2. Give the script the right permissions.

Step 3. Make the script to startup on boot.

  • Boaty Mcboatface

    Nice little script do you have one that would support a list of machines? Not sure how to code this in bash

    • I actually think i can ;) give me a couple of hours

    • I can’t test if this work or doesn’t but let me know if there is any issues with the script and I will try to fix it ;)
      https://gitlab.com/snippets/27708

      • Boaty Mcboatface

        Gave it a bash (hehe) and it didn’t work, I also tired a for loop however it doesn’t load the machine, when done singly this works correctly

        • Hmmm. I am not that strong with bash eiter ;)
          If i was you then i would create a new file for each VM I wanted to autostart and call the file something like Start_VMNAME

          Alternative you can use this code http://hastebin.com/gewoxopuzu.py and make it execute on system startup. I am pretty sure it will work.