Step by step: creating a virtual machine on a headless server
The following instructions may give you an idea how to create a virtual machine on a headless server over a network connection. We will create a virtual machine, establish an RDP connection and install a guest operating system — all without having to touch the headless server. All you need is the following:
- VirtualBox on a server machine with a supported host operating system. The VirtualBox extension pack for the VRDP server must be installed (see the previous section). For the following example, we will assume a Linux server.
- An ISO file accessible from the server, containing the installation data for the guest operating system to install (we will assume Windows XP in the following example).
A terminal connection to that host through which you can access a command line (e.g. via
- An RDP viewer on the remote client; see Section 7.1.1, “Common third-party RDP viewers” above for examples.
Note again that on the server machine, since we will only use the headless server, neither Qt nor SDL nor the X Window system will be needed.
On the headless server, create a new virtual machine:
VBoxManage createvm --name "Windows XP" --ostype WindowsXP --register
Note that if you do not specify
--register, you will have to manually use the
Note further that you do not need to specify
--ostype, but doing so selects some sane default values for certain VM parameters, for example the RAM size and the type of the virtual network device. To get a complete list of supported operating systems you can use
VBoxManage list ostypes
Make sure the settings for this VM are appropriate for the guest operating system that we will install. For example:
VBoxManage modifyvm "Windows XP" --memory 256 --acpi on --boot1 dvd --nic1 nat
Create a virtual hard disk for the VM (in this case, 10GB in size):
VBoxManage createhd --filename "WinXP.vdi" --size 10000
Add an IDE Controller to the new VM:
VBoxManage storagectl "Windows XP" --name "IDE Controller" --add ide --controller PIIX4
Set the VDI file created above as the first virtual hard disk of the new VM:
VBoxManage storageattach "Windows XP" --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium "WinXP.vdi"
Attach the ISO file that contains the operating system installation that you want to install later to the virtual machine, so the machine can boot from it:
VBoxManage storageattach "Windows XP" --storagectl "IDE Controller" --port 0 --device 1 --type dvddrive --medium /full/path/to/iso.iso
Start the virtual machine using VBoxHeadless:
VBoxHeadless --startvm "Windows XP"
If everything worked, you should see a copyright notice. If, instead, you are returned to the command line, then something went wrong.</li>
On the client machine, fire up the RDP viewer and try to connect to the server (see Section 7.1.1, “Common third-party RDP viewers” above for how to use various common RDP viewers).
You should now be seeing the installation routine of your guest operating system remotely in the RDP viewer.</li> </ol> </div>