Headless VirtualBox On CentOS

Home » CentOS » Headless VirtualBox On CentOS
CentOS 10 Comments

Hello listmates,

I am wondering if there is a set of scripts/utilities for automatically starting and running headless (no X11) VM‘s using VirtualBox omn a CentOS 6
server. VNC/RDP access to the VM’s would be fine.

Any help much appreciated.

Cheers,

Boris.

10 thoughts on - Headless VirtualBox On CentOS

  • Hi Boris,

    The command you want is “vboxmanage”

    Usually I’ll start a VM in the usual way (using the GUI), configure networking, and then shut it down.

    Then, to start it headless (assuming the VM is named “mytestvm1”):

    vboxmanage startvm mytestvm1 –type headless

    Other commands that I find useful:

    vboxmanage list vms
    (show all the VMs defined)

    vboxmanage list runningvms
    (show the VMs that are running)

    There’s lots of other subcommands for changing configuration, etc. Typing just “vboxmanage” will show quite a bit of usage information. You can use “vboxmanage controlvm …” to enable/disable RDP, for example.

    -Greg

  • You can also get access to a headless VM console via RDP with VRDE (VBox Remote Desktop Extension) available from VBox Extension Pack.

  • Awesome!

    Thanks for your replies everybody.

    I was looking more or less at the same options. Just was wondering if there was a ready-made set of scripts somewhere to set all of this in motion to save me a little time – but if not, I will just make one.

    Cheers,

    Boris.

  • o If you built a vm client and just want to fire it up as needed, the vbox command line should suffice. Just tell it to start headless. Remember you can later on connect to its console using rdesktop if you configured it.

    o If you want to create the vm from scratch, you can create the vm itself using vboxmanage (a biased example is shown at http://unixwars.blogspot.com/2012/01/creating-virtualbox-vms-command-line.html). Then you could do the initial disk partitioning and installing using, say, kickstart.

    o Another way to do the previous suggestion is to use packer. or JuJu. Or Vagrant. Of the 3, I myself have more experience with packer.

  • You can use vboxmanage modifyvm –autostart-enabled on and enable vboxautostart-service. However I had to tweak the script to suspend VMs on system reboot/shutdown. Don’t know if this works out of the box with newer VBox versions.

  • I’m unfamiliar with vagrant, but it’s pretty easy to roll your own.
    email me off list if you’d like a copy of my Frankenstein scripts.

  • zep writes:

    I should have provided a link: https://www.vagrantup.com/

    vagrant does rather more than just running VM’s – automated creation of VM’s, starting them up, tearing them down. One use case is disposable VM’s typically for developers – spin up a fresh clean VM, pollute it with new code, test and diagnose, tear it down. Rinse, repeat.

    Cheers

    Bob