Create a VirtualBox Headless Machine…

More and more I have been running Virtualbox virtual servers upon my main Ubuntu 10.04 server. I used to create the virtual server upon my Macbook Pro 13″, then export the image, and reimport the image upon the linux headless server. Recently I found it was much easier to create the VirtualBox server upon a headless linux server. Certainly creating the virtual server upon a guy based tool is a lot easier, but it does not save time when you need to export and import the image across to the linux server.

The following steps below will show you howto setup a VirtualBox virtual headless server.

Ubuntu 10.04.03

We now create and register the virtual server with the command VBoxManage.

# VBoxManage createvm -name “server” –ostype Ubuntu_64 –register

We allocated the amount of memory the virtual server will have, the sequence of boot, e.g. dvd first, and which either net adapter does the virtual machine attach itself too. The memory we have allocated is 1024mb and the ethernet it uses is eth4.

# VBoxManage modifyvm “server” –memory 1024 –acpi on –boot1 dvd –nic1 bridged –bridge adapter1 eth4

We now create the hard disk or virtual disk for the virtual server. We allocated 100gb of hard disk space, and store the virtual hard disk file in /home/vbox

# VBoxManage createvdi –filename “/home/vbox/server.vdi” –size 100000

We state that the virtual server uses a ide controller. We can use ahci also, but ide is safe to use.

# VBoxManage storagectl “server” –name “IDE Controller” –add ide

We state that the virtual server uses the ide controller and attach the vital server hard disk to the ide controller.

# VBoxManage storageattach “server” –storagectl “IDE Controller” –port 0 –device 0 –type hdd –medium “/home/vbox/server.vdi”

We need also attach the dvd driver to the ide storage controller. Also we attach the iso image to the dvd drive, so that when we boot the virtual server for the first time, it boots the  virtual dvd driver and uses the iso image.

# VBoxManage storageattach “server” –storagectl “IDE Controller” –port 1 –device 0 –type dvddrive –medium “/home/vbox/ubuntu-10.04.3-server-amd64.iso”

We now allow remote desktop software to connect to the virtual server.

# VBoxManage modifyvm “server” –vrde on”

We now set the port, we can connect to the virtual server on with the remote desktop software. We can connect to the virtual server on port 3392. You can use Microsoft Remote Desktop Connection to connect.

# VBoxManage modifyvm “server” –vrdeport 3392

Once this is all done we can now startup the headless virtual server.

# VBoxHeadless –startvm “server” &

You can shutdown the virtual server with the following command.

# VBoxManage controlvm “server” poweroff

You can pause and restart the virtual server, but within the means of this document, I will not explain them, as they are commands not really needed.