Get Adobe Flash player

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:

VBoxHeadless -startvm

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-804-server-vm.pdf (3134)

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 image001
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

#cd /usr/bin

image002
View all VBox commands in this directory

#ls | grep Vbox

The 2 commands we will use are

VBoxManage

VBoxHeadless

image003
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.

image004
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

image005
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

image006
Set this newly created VDI file as the first virtual hard disk of the new VM:

#VBoxManage modifyvm “CentOS” -hda “CentOS.vdi”

image007
Register the ISO file that contains the operating system installation that you want to install later:

#VBoxManage registerimage dvd /full/path/to/iso.iso

!NOTE!

I registered an Ubuntu .ISO for this step and used it in the remaining steps – even though this is a CentOS VM. ;)

image008
Attach this ISO to the virtual machine, so it can boot from it:

#VBoxManage modifyvm “Windows XP” -dvd /full/path/to/iso.iso

image009
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.

image010
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.

image011

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!

43 Things Tags: , , , , , , ,

Related Posts

  • virtuallyinfallible

    hey thanks for this, its very helpful!
    can you describe what steps need to be changed to accomplish the same thing using the open source edition (OSE) of VirtualBox?

  • virtuallyinfallible

    hey thanks for this, its very helpful!
    can you describe what steps need to be changed to accomplish the same thing using the open source edition (OSE) of VirtualBox?

  • http://vmetc.com rbrambley

    infallible,

    I’ve never used the OSE version of VirtualBox. It obviously does not have the same functionality?

  • http://vmetc.com Rich

    infallible,

    I’ve never used the OSE version of VirtualBox. It obviously does not have the same functionality?

  • Jeff

    Thanks for this. The run VM headless was what I needed to see. Also, love the layout of your walk-through. I need to make a bunch of them for work, I’ll be borrowing your layout.

    -Jeff

  • Jeff

    Thanks for this. The run VM headless was what I needed to see. Also, love the layout of your walk-through. I need to make a bunch of them for work, I’ll be borrowing your layout.

    -Jeff

  • http://vmetc.com rbrambley

    Jeff,

    Glad you like the layout. Have fun with it!

  • http://www.vmetc.com Rich

    Jeff,

    Glad you like the layout. Have fun with it!

  • Jeff

    Rich, Some addition might be:
    — After starting the VM, the guest machine is booting (headless) so there will be a delay before you can connect to it.
    — You can start up your headless VM with a menu icon (no terminal to leave open).
    — Also set up an icon to shutdown your VM machine. I used: /usr/bin/VBoxManage controlvm “Windows XP 1″ poweroff

    -Jeff

  • Jeff

    Rich, Some addition might be:
    — After starting the VM, the guest machine is booting (headless) so there will be a delay before you can connect to it.
    — You can start up your headless VM with a menu icon (no terminal to leave open).
    — Also set up an icon to shutdown your VM machine. I used: /usr/bin/VBoxManage controlvm \”Windows XP 1\” poweroff

    -Jeff

  • For

    When you start a virtual machine headless, shouldn't it go into the background? The GUI version requires you to keep a console window open, which I'm confused by. I'd rather (like in VMWare) start the machine and have certain VMs automatically boot up, unattended in the background, for use.

  • Pierre

    To run you vm in the background use the '&' it's a linux thing so not only for VBoxHeadless

    like this:

    VBoxHeadless startvm MyBigVM &

  • Pierre

    To run you vm in the background use the '&' it's a linux thing so not only for VBoxHeadless

    like this:

    VBoxHeadless startvm MyBigVM &

  • Adrian

    So glad I found this – it was exactly what I was looking for. Thank you for this it is perfect. Easy to follow and still works with VirtualBox 3.0.10. I have been looking for something like this.

  • http://vmetc.com rbrambley

    Adrian,

    Glad to help!

  • Pingback: Virtual Box in Headless Mode, RDP, Sun Rays, Mac …. | Geek 2.0

  • Praveerai

    Nice document and usefull one Thanks a lot …….

Badges

follow-me-twitter

I blog with Blogsy

Comments / DISQUS