Setting Up A VirtualBox Guest On A Headless Linux Host

Thursday, August 11, 2011

VirtualBox comes with a rather nice commandline interface, and here’s how you’d work it. The following commands have not changed much since VirtualBox 3.1, and they have just been tested on VirtualBox 4.1.

Before we start, here’re the guest specifications that we’re looking for…

  • VM name mustard
  • RAM 1 GiB
  • SATA controller with 20 GiB disk at mustard.vdi
  • IDE controller with CD/DVD at installer.iso
  • Bridged networking using host adapter eth0
  • OS Windows 7

Create machine and disk…

VBoxManage createvm --name mustard --ostype Windows7 --register
VBoxManage modifyvm mustard --memory 1024 --acpi on --boot1 dvd --nic1 bridged --bridgeadapter1 eth0
VBoxManage createhd --filename mustard.vdi --size 20480

Create SATA controller and attach disk…

VBoxManage storagectl mustard --name “SATA Controller” --add sata --controller IntelAhci
VBoxManage storageattach mustard --storagectl “SATA Controller” --port 0 --device 0 --type hdd --medium mustard.vdi

Create IDE controller and add disc…

VBoxManage storagectl mustard --name “IDE Controller” --add ide --controller PIIX4
VBoxManage storageattach mustard --storagectl “IDE Controller” --port 0 --device 0 --type dvddrive --medium installer.iso

The proprietary version of VirtualBox exports a nifty RDP service that you can use to set up the machine. With VirtualBox 4+, the proprietary extensions come in a separate package. Note that the local and remote mouse cursors are not synchronized, so it may be somewhat difficult to operate. Starting the machine is simple…

VBoxHeadless --startvm mustard

After installation, I’d recommend setting up RDP from within Windows (or SSH in a UNIXy guest), because of the subpar VirtualBox RDP experience. If you want, change the boot order and remove the installer CD/DVD…

VBoxManage modifyvm mustard --boot1 disk
VBoxManage storageattach mustard --storagectl “IDE Controller” --port 0 --device 0 --medium emptydrive

… and that’s that! Since I’m using an Ubuntu host, my next post deals with how to start and suspend this VM during boot and shutdown.

One Comment

    Pingbacks & Trackbacks

    1. inportb » Managing A VirtualBox Guest Using Upstart - Pingback on 2011/08/11