Creating Oracle VirtualBox virtual machine from command line

This is how you create, on a server without a GUI, a  virtual machine with 128 MB RAM and 5 GB HDD, with a virtual network adapter (enabling you to connect to it by a Remote Desktop client), and with a Microsoft Windows installation disk image in the virtual DVD drive:

VBoxManage createvm --name "WinXP" --register
VBoxManage modifyvm "WinXP" --memory 128 --acpi on --boot1 dvd --nic1 bridged --bridgeadapter1 eth0 --ostype WindowsXP
VBoxManage createhd --filename WinXP.vdi --size 5000
VBoxManage storagectl "WinXP" --name "IDE Controller" --add ide
VBoxManage storageattach "WinXP" --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium WinXP.vdi
VBoxManage storageattach "WinXP" --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium WinXP.iso

The virtual machine now is ready.

Before you start it, run ifconfig to find out the IP address of the host system (e.g.

Then start the newly created virtual machine:

VBoxHeadless --startvm "WinXP" &

Then use a Remote Desktop client on another computer to connect to the virtual machine for getting on with the MS Windows setup. If you choose to use rdesktop for this purpose, your command might look like this (with the sample address from above; the port number is optional):

rdesktop -a 16 -N

Note: You may experience a problem with double mouse cursor in your RD client. If you are not planning to use the Remote Desktop connection to the host system (as opposed to the guest system inside the virtual machine), then you just may try to click your way through the installation as good as you can. (An advise: try moving the mouse cursor outside of the client’s window and bringing it in from various sides – it may help you to minimize the distance between the real and the “ghost” cursor.) Otherwise you shall install so called Guest Additions for better system integration (see below). Guest Additions basically are just a set of drivers for virtual devices, to be installed from within your MS Windows installation just as you would normally do it.

After you complete the MS Windows setup and your new Windows desktop is running, you may go to the Windows network adapter configuration, find out its IP address, then disconnect your RD client from the IP address of the host system and connect anew to the newly found IP address of the virtual adapter of your virtual machine. You will be connected to the Microsoft Remote Desktop server within the virtual machine, instead of the VirtualBox’s own Remote Desktop server ( Just remember to allow remote access by going to the Control Panel -> System Properties -> Remote Desktop -> Allow ).

At the host system you now may remove the MS Windows install media from the virtual DVD drive. You don’t need it anymore:

VBoxManage modifyvm "WinXP" --dvd none

If you want to install the Guest Additions, you first shall download the .ISO disk image (for example the one for VirtualBox 4.2.6 you can get here). You may make a link with a shorter name to the .ISO file for easier reference (e.g. guest.iso). Then you shall mount it for the OS in the virtual machine to see it. Which may look like this:

VBoxManage storageattach "WinXP" --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium guest.iso

Now MS Windows shall be able to see the disk VirtualBox Guest Additions in its CD-ROM drive. Autorun will start the installation. Otherwise just start it manually. The double mouse coursor (if any) will be gone and overall the installation, obviously, is supposed to work smoother…

Useful links:


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 )

Google+ photo

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

Twitter picture

You are commenting using your Twitter 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.