Ubuntu Server + VirtualBox 3.1 + Windows Server 2008 over VRDP
- Details
Yesterday the disk in my server went on strike. Even though I recovered the partition table successfully thanks to TestDisk, my Gentoo had trouble seeing the partitions (I tried configuring it every which way and none of it helped).
So I put Ubuntu Server 9.10 on it for testing, worked my way through the manual, and I have a box for my rsync backups again. I wonder whether it can host a virtual machine, say with Windows on it, and let me connect to it remotely... IT CAN :) and it is not particularly complicated.
This article is about creating virtual machines by hand. These days I would recommend using phpVirtualBox instead
Here are instructions for VirtualBox 1.5.2; VirtualBox is currently at version 3.1 and those instructions no longer quite fit it. So here is the procedure as it worked in my case
- Adding the package sources
First you have to add the repository for this Ubuntu release to your repository list (/etc/apt/sources.list)
deb http://download.virtualbox.org/virtualbox/debian karmic non-free
We have to use Sun's repositories, because the packages available in Ubuntu by default do not include the RDP, USB and USB over RDP features (those are in the closed edition of VirtualBox) About the VirtualBox editions.
Repositories for other distributions - Installing VirtualBox
sudo apt-get install virtualbox
- Creating and installing the virtual machine
This is where most of the trouble was. The following sequence of commands creates a virtual machine:
VBoxManage createvm -name "ws2008" -register VBoxManage modifyvm "ws2008" --memory 512 --acpi on --boot1 dvd --nic1 intnet VBoxManage createvdi --filename "ws2008.vdi" --size 10240 --register VBoxManage storagectl "ws2008" --name "IDE Controller" --add ide VBoxManage modifyvm "ws2008" --hda "ws2008.vdi" VBoxManage registerimage dvd /storage/isos/ws2008.iso VBoxManage storageattach "ws2008" --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium /storage/isos/ws2008.iso VBoxManage modifyvm "ws2008" --vrdpport 3390
- Create and register the machine
- Configure the machine: 512 MB RAM, ACPI on, boot from DVD, internal network
- Create and register a 10 GB disk image
- Add an IDE controller to the machine. (This was missing from the instructions for earlier versions; if any of you hit the error ERROR: Could not find a storage controller named 'IDE Conroller', that is exactly why - the machine had no IDE controller discussion on the VirtualBox forum )
- Attach the disk image to the machine.
- Register the image of the Windows installation disc
- "Insert the disc" into the virtual DVD drive (I am not sure the previous step was necessary, since I give the path here anyway; this step also differs from the 1.5.2 instructions quoted earlier)
- Set the port for VRDP (Virtual Remote Desktop Protocol)
- Starting the machine
VBoxVRDP -startvm "ws2008"
- Connecting with remote desktop
Now all you need is to connect to the machine with remote desktop on the port you set, in this example server:3390
- Naturally, until the Guest Additions are installed the mouse pointer will behave oddly :)
VBoxManage storageattach "ws2008" --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium /usr/share/virtualbox/VBoxGuestAdditions.iso
- Internet
If you need the machine to reach the internet, attach NAT (with the virtual machine shut down):
VBoxManage modifyvm "ws2008" --nic1 nat
- We can also forward a port of the virtual machine so that it is reachable from outside:
VBoxManage setextradata "ws2008" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP VBoxManage setextradata "ws2008" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 3389 VBoxManage setextradata "ws2008" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 3389
where guestssh is the name we gave the forwarding rule (I kept the name from the example in the VirtualBox wiki)
- Now we can connect to our Windows either over the VRDP that VirtualBox provides, or over Windows' own RDP. :D