Running VirtualBox VMs as headless servers allows you to launch and edit the machines without all the desktop interface...
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
Virtualization administrators are probably familiar with the concept of a headless server: a system with no monitor or display hardware, that's accessed entirely across a network. Virtual machines (VMs) and cloud-based servers are headless by default, but desktop virtualization brings a whole new meaning to the term.
More on VirtualBox VM management
VM recovery with VirtualBox: Two ways to salvage data
Creating virtual machines with Oracle VM VirtualBox
VMware Workstation vs. VirtualBox
Oracle VM VirtualBox is for the most part a desktop application, which means interaction with any system virtualized with VirtualBox is done through the product's desktop interface. It's possible to interact with any virtualized system over the network or through VirtualBox's remote display system, but you usually need to launch the desktop graphical user interface (GUI) to do that. However, if you don't need to interact with a given machine via the GUI for any other reason, it's pointless to launch it. All it does is create unnecessary memory overhead and desktop clutter.
To run VMs without accessing the GUI, VirtualBox has a special management application called VBoxHeadless. It's a command-line app for launching VirtualBox VMs as headless servers and managing their connection requirements.
Starting a VM in headless mode
There aren't as many management options for VBoxHeadless as there are for the VBoxManage app: It only deals with starting, stopping and making connections to VMs in headless mode.
For instance, the command VBoxHeadless -- startvm "VM name" starts the VM in headless mode (Figure 1).
The VBoxHeadless command-line tool can start this VM named "Linux test box."
When starting a VM or reactivating a suspended one, VBoxHeadless provides information about the state of the VM, including which port the VRDP server for that VM is using. (VRDP is the VirtualBox Remote Desktop Protocol, an extension of Microsoft's Remote Desktop Protocol.) This is useful if you're trying to figure out why a VM won't launch.
After launching the VM, VBoxHeadless remains running on the console, meaning it won't return you to the command line. All you need do from there is connect to the VM via VRDP.
When you start VirtualBox VMs in headless mode, they're automatically provisioned with a VRDP connection port -- even if you didn't have one set up for the VM previously. If you'd rather have a VRDP port provisioned ahead of time for a VM (to avoid port-collision problems, for instance), you can do this one of two ways: via the regular VirtualBox GUI (since you can edit the VRDP connection information through the GUI without having to suspend or shut down the VM), or through the VBoxHeadless --e command line switch. I typically set the VRDP connection information once through the GUI, because it's less convoluted that way.
There are a couple situations where you may not want a VRDP port provisioned no matter what: if you're accessing the server only through SSH or a Web interface, for example. To force VRDP off when launching VirtualBox VMs as headless servers, use the --vrde=off switch in VBoxHeadless.
Making changes to headless VirtualBox VMs
As you might guess, headless servers don't need to have the main VirtualBox GUI running to be functional. However, if you start the VirtualBox GUI while you have headless servers running, you can edit its properties and see a thumbnail view of the VM's display in the Preview section (Figure 2). If the server is, say, a Linux appliance that boots to a command line, you’ll see a screen with a command line on it. Plus, if you connected via VRDP, you'll be able to interact with that command line as if typing on a local console.
This preview thumbnail is updated live as changes take place on the server.
If you have a VM running in headless mode but you want to open a local GUI for it, you can suspend the headless VM from the command line, then resume it through the VirtualBox GUI. This opens the interface for that VM on the desktop. You can do the same thing in reverse as well: Just suspend the VM through the VirtualBox GUI and resume it with VBoxHeadless.
That doesn't appear to trigger any hardware disconnections on the part of the VM, such as its display being unplugged or reattached. Display hardware is always virtualized for the running VM even if there is no GUI for it. Think of it more in terms of the monitor simply being turned off rather than disconnected.
Lastly, you should also be aware that the main VBoxManage command-line app has a --type switch you can use to invoke a VM in headless mode. If you want to start a headless VM that way, use the command VBoxManage startvm "name of VM" --type headless.