Starting your VM in VirtualBox in Headless Mode by default

Every now and then, I try to save myself a few clicks by trying to get a tool to behave in the way I prefer. Most of the time I can get what I want by digging through the settings and finding the right knob to turn.
When it comes to this specific behaviour, the tool wouldn’t let me set it up the way I needed.

What do I need, and in what tool you might ask?

How to start your VM in VirtualBox in Headless Mode by default.

Used software:
Oracle VirtualBox 5.x (5.2.22 to be precise)

Every time I wanted to start any of these two Linux VM’s, I found myself clicking the tiny dropdown icon and select the option ‘Headless Start’. That is two clicks, of which one is really precise as the dropdown area is pretty small.

And I figured: there has to be a better way to do this!
As it turns out, there’s been an option to select the default method for starting a VM in VirtualBox for ages, it’s just not being shown in the GUI.
All you need to do is navigate to the install location of VirtualBox (or make sure it is on the PATH of your machine) and execute the following command:

VBoxManage modifyvm "<vmname>" --defaultfrontend headless

And that’s all!
You can still select another option for starting, it just defaults to whatever you choose to run your command with.

Valid options are:

  • gui
  • headless
  • separate

Find out more by reading the source or the documentation.