VirtualBox through the command line only

VirtualBox has come pretty damned far, I have to give them that! It originally was geared towards desktop users who wanted to virtualize, now it’s only a few steps from being a contendor with Enterprise solutions. Not VMWare (yet), but some polishing and it’ll get there.

That being said, I wanted to throw a quick and concise command-line driven walk-through on creating a virtual machine in VirtualBox and booting from a CD/DVD image to install. It’s pretty straight forward, but instead of bumping against the walls for the first time, here it is:

# Register/create a VM slot in the system. ‘CentOS’ is the Virtual Machine Name we’ll use throughout.
VBoxManage createvm -name “CentOS” -register

# Modify the slot to your preference. ‘ostype’ is variable, the options can be seen by using ‘VBoxManage list ostypes’. cpuexecutioncap is 0-100 on percentage of CPU to use for this VM.
VBoxManage modifyvm “CentOS” –ostype RedHat_64 –memory 4192 –acpi on –cpuexecutioncap 100 –hwvirtex on –boot1 dvd –nic1 nat

# Creating the Host image (10G). Change the path and name of the file to your use. The size is 1024 * number of Gb desired.
VBoxManage createhd –filename /Users/situationalawareness/Virtualbox/VMs/CentOS –size 10240 –format VDI

# Add the IDE Controller.
VBoxManage storagectl CentOS –name “IDE Controller” –add ide

# Just to verify it boots from the dvd
VBoxManage modifyvm CentOS –boot1 dvd

# Attaches the Host image to the IDE controller, first slot. Change the path and file to your host file created above.
VBoxManage storageattach CentOS –storagectl “IDE Controller” –port 0 –device 0 –type hdd –medium /Users/situationalawareness/Virtualbox/VMs/CentOS.vdi

# Attaches the DVD image to the IDE Controller, second slot. Change path and file to your ISO image information.
VBoxManage storageattach CentOS –storagectl “IDE Controller” –port 1 –device 0 –type dvddrive –medium “/Volumes/misc 1/iso/CentOS-6.0-x86_64-bin-DVD1.iso”

# Configure VM to allow RDP connectivity upon boot
VBoxManage modifyvm CentOS –vrde on –vrdeport 3340

(The extensions from Oracle are necessary for VRDE to function.

After that, I just start the headless virtual machine with “VBoxHeadless -s CentOS &” to push it into the background.

You can see what’s running with “VBoxManage list runningvms”.
For more details, see

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.