Creating and Configuring Headless VMs in VirtualBox
I already commented about Rick Vanover’s series of articles on Sun’s xVM VirtualBox, but I decided to make a more detailed how to tutorial on using the headless RDP features. This tutorial explains a step by step process for remotely creating virtual machine hardware, installing the VM operating system, and managing the VM using the VBoxHeadless console command. This post uses the steps from the VirtualBox User Manual found in Section 7.4 titled Remote Virtual Machines (VRDP support)
The following information is copied from the User Manual and provides a good general overview of the goal of this tutorial:
“VirtualBox therefore comes with yet another front-end that produces no visible out-put on the host at all, but instead only delivers VRDP data. With VirtualBox 1.6, this “headless server” is now aptly called VBoxHeadless. (In previous versions, it was called VBoxVRDP. For the sake of backwards compatibility, the VirtualBox installation still installs an executable with that name as well.)
To start a virtual machine with VBoxHeadless, you have two options:
- You can use VBoxManage startvm -type vrdp. The extra -type option causes the VirtualBox core to use VBoxHeadless as the front-end to the internal virtualization engine.
- The recommended way, however, is to use VBoxHeadless directly, as follows:
This is the recommended way, because when starting the headless interface through VBoxManage, you will not be able to view or log messages that VBoxHeadless may have output on the console. Especially in case of startup errors, such output might be desirable for problem diagnosis.”
Although using the VboxHeadless command is simple, it is a series of console commands. This can be considered inconvenient to many administrators that are used to the point and click functionality of VMware’s products. In my opinion, it would nice to see VirtualBox release a web gui or a toolkit of scripts that can automate these commands. The VirtualBox user community has published some scripts for basic headless VM administration, but I could not find any scripts that actually create new VMs.
Read on for the tutorial.
Here’s a .pdf version for those readers that have trouble reading this in Internet Explorer (download also available from the Files page)
Headless VM creation in VirtualBox – Creating an Ubuntu 8.04 Server VM
In this tutorial I will remotely create a CentOS VM for VirtualBox using the VboxHeadless command
|Establish SSH connection to remote VirtualBox Server Host|
|Locate VboxHeadless command
On Ubuntu 8.04 workstation us e find command (case sensitive command!)
#find / -name VboxHeadless
Multiple locations found, but we need the command in the /usr/bin directory
change to /usr/bin directory
|View all VBox commands in this directory
#ls | grep Vbox
The 2 commands we will use are
|On the headless server, create a new virtual machine:
#VBoxManage createvm -name “CentOS” -register
Note that if you do not specify -register, you will have to manually use the registervm command later.
|Make sure the settings for this VM are appropriate for the guest operating system that we will install. For example:
VBoxManage modifyvm “CentOS” -memory “512MB” ’ -acpi on -boot1 dvd -nic1 nat
This command does the following:
assigns 512mb RAM
turns on acpi
boots the VM from the DVD
configures the nic to use NAT
|Create a virtual hard disk for the VM (in this case, 10GB in size) and register it with VirtualBox:
#VBoxManage createvdi -filename “CentOS.vdi” -size 10000 -register
commands creates a 10GB vdisk
|Set this newly created VDI file as the first virtual hard disk of the new VM:
#VBoxManage modifyvm “CentOS” -hda “CentOS.vdi”
|Register the ISO file that contains the operating system installation that you want to install later:
#VBoxManage registerimage dvd /full/path/to/iso.iso
I registered an Ubuntu .ISO for this step and used it in the remaining steps – even though this is a CentOS VM. 😉
|Attach this ISO to the virtual machine, so it can boot from it:
#VBoxManage modifyvm “Windows XP” -dvd /full/path/to/iso.iso
|Start the virtual machine using VBoxHeadless:
#VBoxHeadless -startvm “CentOS”
If everything worked, you should see a copyright notice. If, instead, you are
returned to the command line, then something went wrong.
|On the client machine, fire up the RDP viewer and try to connect to the server.
Assuming a Linux client, try the following:
#rdesktop -a 16 my.host.address
(With rdesktop, the -a 16 option requests a color depth of 16 bits per pixel, which we recommend. Also, after installation, you should set the color depth of your guest operating system to the same value.)
You should now be seeing the installation routine of your guest operating system.
Sorry for the mix up on the screen shots using the Ubuntu Server ISO for this CentOS VM. The process should still be understandable … hopefully!
[ad] Empty ad slot (#1)!