DISQUS

Far Fewer Toes: Start VirtualBox virtual machines on boot | Far Fewer Toes

  • raymond · 1 year ago
    This is a great soluton! I have been looking for something like this for a long time.

    What if I'm not using a tap interface will this script still work? Is there an option to disable the loading of the tap interface?

    Why not use the VBoxRDP command to start the VMs?
  • Jochem · 1 year ago
    Hi Raymond, thanks for the compliment.

    Right now the script only works with tap interfaces, since I didn't have a need for non-tap based VM's. Adding an option for that would be easy though, I guess. If so, I'll post a new version soonish with the option in it.

    I use the VBoxManage command since that can do all actions to a VM needed, like shutting down (VBoxRDP can't do this afaik), listing running VM's etc. I don't think there's any advantage of running VBoxRDP for just starting the VM's.
  • raymond · 1 year ago
    Hi Jochem,

    Thanks for the quick response.

    The only difference with using VBoxRDP for starting the VM is that it will show up in the log if there are any problems when starting it.

    I'm looking forward to your updated script.

    PS. I believe you should post a link inside the VirtualBox forum for other s to find this wonderful script of yours. Believe you me there are many others who would like to be able to do this on their linux box but don't know how to code the script.
  • esoco · 1 year ago
    Thanks for this helpful script, it works without problems on Ubuntu 8.04 for me. I only noticed a small typo in the instructions: the entry in interfaces mentioned here
    * If you use 'Host interface' networking, put a br0 entry in /etc/network/interfaces: inet br0 inet dhcp

    must instead be "iface br0 inet dhcp".
  • Jochem · 1 year ago
    Thanks esoco, you're right. It's fixed in the vboxcontrol section
  • Lei · 1 year ago
    It's a great script I have been looking for.

    The version 2008051100 by Jochem does not work for my setup:

    Sun xVM 1.6.2 under Ubuntu Server 8.04

    so that I have adapted it and named version 20080615-1915. It is sent to Jochen to post in the hope that it may be useful for some people. It was just tested in my abovementioned setup and I am not sure if it would work on Ubuntu Desktop or any other Linux distributions, which I am not using and unable to test with.
  • timbophillips · 1 year ago
    great work jochem, that solved a problem i was having with a server running several virtualbox VMs. two extra bits that have helped me...

    i add the lines
    bridge_fd 0
    bridge_stp on
    in the br0 section of /etc/network/interfaces
    on big networks this avoids the situation where the bridge isn't in listening mode by the time virtualbox is plugging its VMs onto the taps

    in your vboxcontrol script (fantastic script by the way) i added a few lines to the waiting_for_closing_machines() method to give the VMs a minute or so to close themselves in response to the ACPI powerbutton... if a minute goes by and they haven't closed I assume they've hung and use 'poweroff' to pull the plug on them.

    code below....

    wait_for_closing_machines() {
    RUNNING_MACHINES=`$SU "$VBOXMANAGE list runningvms" | wc -l`
    if [ $RUNNING_MACHINES != 0 ]; then
    sleep 5

    # =========================================================
    # added by Tim; give them a few cycles to shutdown then kill them
    # =========================================================
    x=$(expr $x + 1)
    log_action_msg "waiting for them to shut-down as instructed - $x"
    if [ $x = 10 ]; then
    log_action_msg "$RUNNING_MACHINES VM(s) seem to be hung..."
    $SU "$VBOXMANAGE list runningvms" | while read HUNGVM; do
    log_action_msg "Powering off VM: $HUNGVM ..."
    $SU "$VBOXMANAGE controlvm \"$HUNGVM\" poweroff"
    done
    fi
    #========================================================

    wait_for_closing_machines
    fi
    }
  • robp2175 · 1 year ago
    How do I remove this script "update-rc.d vboxcontrol defaults 99 10" .
    It did not work for me and I want to make sure it does not try to run every time I boot.
  • Jochem · 1 year ago
    Hi robp2175, you can remove the script with:
    update-rc.d -f vboxcontrol remove

    (see man update-rc.d)
  • makj · 9 months ago
    i've made a few minor changes to your script in order to be able to run it in gentoo:

    1. in gentoo doesn't exist /lib/lsb/init.functions, i've commented it out
    2. because of (1), i substituted the commands: log_failure_msg and log_action_msg, instead i used a simple 'echo'
    3.in gentoo doesn't exist the file /etc/network/interfaces, instead the config of the network is in /etc/conf.d/net
    4. i need to open the VMs with it's GUI (windows, you know...), so i've set an X-server and add it to the config file asa variable: X_HOST
    5.i used X_HOST for setting the target of the GUI of the VM using "export DISPLAY=$X_HOST"
    6.i've changed the type of the VM's, instead or "-type rdp" i use "-type gui"

    the rest works perfectly, but i have still a problem with the network, i cant see any host from the guest (windows 2003), any help?