From HyperV to KVM to VirtualBox

HyperV had miserable support for non-Windows guest operating systems, I couldn't get my DVD backup software working when mapped to the hypervisor's physical DVD drive, and the storage I/O was pretty miserable.

I then set out to run everything on KVM, using Ubuntu 10.10 for the base OS.

That worked ok for basic things, but KVM has even worse support for pass-through to physical devices. I couldn't even boot a KVM guest unless I had media in the optical drive, and I couldn't attach/detach the drive after the guest was booted. Useless.

I thought about upgrading to the latest qemu & KVM (Ubuntu 10.10 ships with old versions) but I decided to scrap it all and go with VirtualBox. VirtualBox has served me well in the past, so now I'm going to give it a go.

I present to you ... VirtualBox 4 on Ubuntu 10.10. Headless.

Special thanks to this article on HowtoForge.

First, I stopped KVM:
sudo service qemu-kvm stop

Then I blacklisted the KVM modules so they don't come back at the next startup:
sudo vi /etc/modprobe.d/blacklist.conf

Then add the following lines:
 blacklist kvm
 blacklist kvm-intel
 install kvm /bin/true
 install kvm-intel /bin/true

To install VirtualBox, I first added VirtualBox's repository to APT.
sudo vi /etc/apt/sources.list

I then added the following line for Ubuntu Maverick (10.10):
deb maverick contrib

To finish the APT setup, I added's key:
wget -q -O- | sudo apt-key add -

APT is now ready to install VirtualBox:
sudo apt-get install linux-headers-$(uname -r) build-essential virtualbox-4.0 dkms

For VirtualBox's Remote Desktop (RDP) server, you need the "extension pack". I guess this one doesn't come from the repository, so I downloaded it with wget.
cd /tmp


With sudo, I ran the installer:

sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.0.4-70112.vbox-extpack

I'm running my VM's under a dedicated user named vbox.
sudo adduser vbox
sudo adduser vbox vboxusers

Since I don't want my virtual machine's in the vbox user's home directory, I'm going to put them in /opt.
mkdir /opt/virtualbox/
sudo chown vbox:vbox /opt/virtualbox/
sudo chmod 770 /opt/virtualbox/

Ok, now it's time to create some VMs. First up - I need a Windows 2008 server to run Subsonic (media streaming) and PS3 Media Server.

Now I'm logged in as vbox.
vbox@myserver:/opt/virtualbox/$ VBoxManage createvm --name "subsonic-win" --ostype Windows2008_64 --register --basefolder /opt/virtualbox/

It will give you some handy output, including the UUID of the new VMs. I'm using the UUID in the following commands.

First I'm adding memory & mapping the virtual NIC to eth0 (I don't have the bonds working yet), and telling it to put a listener on TCP/4389 for Remote Desktop to the console.
VBoxManage modifyvm 53294d05-2c07-4dae-af6e-6e53ee06aa85 --memory 1024 --acpi on --boot1 dvd --nic1 bridged --bridgeadapter1 eth0  --vrde on --vrdeproperty TCP/Ports=4389

Next up - creating the virtual disk image.
VBoxManage createhd --filename /opt/virtualbox/subsonic-win/subsonic-win-0.vdi --size 10000

Next I added a SATA controller.
VBoxManage storagectl 53294d05-2c07-4dae-af6e-6e53ee06aa85 --name "SATA Controller" --add sata

And then attached my new disk.
VBoxManage storageattach 53294d05-2c07-4dae-af6e-6e53ee06aa85 --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium /opt/virtualbox/subsonic-win/subsonic-win-0.vdi

And then the W2K8 install ISO:
VBoxManage storageattach 53294d05-2c07-4dae-af6e-6e53ee06aa85 --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium "/media/software/Windows/Microsoft/Windows Server 2008/en_windows_server_2008_r2_standard_enterprise_datacenter_web_x64_dvd_x15-50365.iso"

And finally - startup!
VBoxHeadless --startvm 53294d05-2c07-4dae-af6e-6e53ee06aa85 --vrde on --vrdeproperty TCP/Ports=4389

At this point, I was able to connect using RDP on port 4389 and watch the console as the VM booted. Nice and easy.

Once I finished installing Windows, I used this command from the host to attach the Guest Additions ISO to the new guest.

VBoxManage storageattach 53294d05-2c07-4dae-af6e-6e53ee06aa85 --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium "/usr/share/virtualbox/VBoxGuestAdditions.iso"

No comments:

Post a Comment