Headless Mode for Virtual Machines of VirtualBox

From Thomas-Krenn-Wiki
Jump to navigation Jump to search

VirtualBox offers exceptional options for managing virtual machines (VMs) from the command line using the VBoxManage utility.[1] Headless mode is a useful feature for starting virtual machines. Thereby, the virtual machine will not be started from the VirtualBox GUI, but rather from the command line. A graphical popup window with the virtual machine’s console will not appear. Instead, a connection will be initiated through a remote desktop or SSH connection.

VirtualBox Remote Display Protocol (VRDP)

Installing Extension Packs

Displaying a virtual machine started in headless mode can be achieved through VRDP.[2] To be able to use VRPDP, the extension package for VirtualBox must have been installed. It can be downloaded from the download page and installed by means of the VirtualBox GUI:

If the VirtualBox remote display extension has not been activated, the procedure can be repeated by means of:[2]

~$ VBoxManage modifyvm "VM name" --vrde on

Starting and Connecting to the Virtual Machine

After the successful installation of VRDP, a virtual machine can be started in headless mode. The name of the virtual machine will be given in the first step:

~$ VBoxManage list vms
"ubuntu-server" {763d57b9-8eef-4572-8e71-f33fea89e950}

In this example, there is a virtual machine named "ubuntu-server". The subsequent number is its UID. Headless mode can be activated afterwards in one of two manners:

~$ VBoxHeadless -s ubuntu-server
Oracle VM VirtualBox Headless Interface 4.1.8
(C) 2008-2011 Oracle Corporation
All rights reserved.

VRDE server is listening on port 3389.

or:

~$ VBoxManage startvm ubuntu-server --type headless
Waiting for VM "ubuntu-server" to power on...
VM "ubuntu-server" has been successfully started.

The virtual machine will now be running, however display output will not be shown. Instead, one connects to the machine through RDP or SSH (assuming that corresponding network and SSH configurations) exist.

SSH

~$ ssh tktest@192.168.56.101

In this example, the virtual machine has one Host-only-Adapter, which will automatically get an IP address from the DHCP server when the virtual machine is started. For that reason, the running SSH server for the virtual machine can be reached without any problems. This connection will also work through SSH, if VRDE has not been activated for the virtual machine.

RDP

Connection to a virtual machine via RDP will only work when VRDE has been activated for the virtual machine. After that, any RDP client can be used for connecting to the local host or using the IP address for the host on the virtual machine:

~$ VBoxHeadless -s ubuntu-server
Oracle VM VirtualBox Headless Interface 4.1.8
(C) 2008-2011 Oracle Corporation
All rights reserved.

VRDE server is listening on port 3389.
rdesktop localhost
A connection is created via RDP for starting the virtual machine in headless mode.

References

  1. VBoxManage (Oracle VM VirtualBox User Manual, Chapter 8)
  2. 2.0 2.1 Remote virtual machines: Remote display (VRDP support) (Oracle VM VirtualBox User Manual, Chapter 7)

Related articles

64 bit guests in VirtualBox
Shared Folders of VirtualBox
Windows XP Installation in VirtualBox