VirtualBox useful commands (VBoxManage/VBoxHeadless)

[bash gutter=”false”]
# change VirtualBox disk and machine default location
VBoxManage setproperty hdfolder /volumes/data/vbox
VBoxManage setproperty machinefolder /volumes/data/vbox

# create a VM
VBoxManage createvm –name "U10.4-base" –ostype Ubuntu –register
# add some ram, network card, DVD-ROM
VBoxManage modifyvm "U10.4-base" –memory 128 –acpi on –boot1 dvd –nic1 bridged
# create a HDD
VBoxManage createhd –filename U10.4-base.vdi –size 10000 –register

# attach storage controllers to it
VBoxManage storagectl "U10.4-base" –name "IDE Controller" –add ide
VBoxManage storageattach "U10.4-base" –storagectl "IDE Controller" –port 1 –device 0 –type dvddrive –medium none

# remove .iso
VBoxManage closemedium dvd /volumes/data/exchange/mini-ubuntu-10.04-server-i386.iso

# start VM
VBoxHeadless –startvm "U10.4-base"

# stop VM (requires package acpid)
VBoxManage controlvm "U10.4-base" acpipowerbutton

# view VM information
VBoxManage showvminfo "U10.4-base"
[/bash]