Sunday, March 21, 2010

Playing with VirtualBox

I have begun to experiment with VirtualBox as a virtualization tool for testing OS's on my computer.  I previously used the free versions of MSVS and VMWare but as VirtualBox is gaining popularity I wanted to get some experience with it.

A couple of weeks ago I received a new laptop at work with Win7 on it.  My prior laptop had been running Win7 RC which was due to expire at the end of February.  On the old laptop I had been running a free version of VMWare Server to host a few virtual machines for testing out Windows Server 2003 and a CentOS distro.  I had ported those VMs over my last two laptops running XP and onto the Win7 RC system with VMWare Server, which saved quite a bit of installation and setup time for these test VMs.  Under VMWare they ran just fine on a Core2Duo laptop with 2GB of RAM.  They were not blazing fast of course but my needs were not for performance but simply for occasional testing of OS functionality.

Rather than install VMWare on my new laptop I decided to try out VirtualBox to see what its pros and cons were and how effective (or painful) it might be to use.  This software is something that we are thinking about recommending to some of our field IT staff as a useful tool for them to gain experience with new OS's without having to dedicate additional precious hardware.  In our office we have pretty strong Linux skills and most of our production systems are virtualized with Xen on CentOS.  We have had some discussions about moving toward KVM as it will be better supported in CentOS in the longer term, but when it comes to VMs on workstations most of the team are using VirtualBox.

This blog entry documents my notes along the way of installing and learning VirtualBox.  I hope they will be of use to others who are also considering this technology.

I Googled VirtualBox and then downloaded the 3.1.4 version's 72 Meg Windows binary installer from the web site.  While it was downloading, I reviewed the FAQs for Windows (nothing of critical issue - use dynamic disk sizes versus fixed) and also grabbed a copy of the User Manual PDF, both from the official web site.

Side Note:
By the way, I'm running Win7 32-bit, as my experience with the 64-bit RC revealed that too few applications are actually available in 64-bit flavors to make it worth the trouble.  It doesn't appear that VirtualBox is available for Intel 64-bit Win7 (AMD64 yes, but I don't see references to Intel 64.)  I don't yet know if the 32-bit VirtualBox will run under 64-bit Win7 in 32-bit mode.  It's for reasons exactly like this that I decided to stick with 32-bit Win7 for now.  While Win7 64-bit did run most 32-bit apps without trouble, there were enough installation quirks and a big lack of available apps that actually would benefit at all from 64-bit performance, so I decided to step back to 32-bit for a while until the market matures a bit more.

Installation
I installed the software with the default settings.  It does warn that during the installation of the networking components you will be temporarily disconnected from the network, so I saved any open files (this blog) and closed other programs like Outlook, which gets unhappy when it looses its MAPI connection to the server...  Windows security prompted me 4 times during the installation process about allowing drivers to be installed for USB and network support, but the installation was straight forward.  I wonder how much overhead the VirtualBox network drivers will take up.  The VMWare Server network drivers caused my prior XP and Win7 PCs to boot up and shut down noticeably slower.  After finishing the installation, launching the program and navigating through the registration box, I was presented with the VirtualBox UI.

I browsed around the application menus a bit - shucks, you can't import VMWare VMs.  I was sort of hoping something like this would be available as it would save me some long install and configuration processes, but it's understandable how impossible it might be to import an image from another technology and actually make it work!  Next I looked at my laptop's network drivers to see what damage it did to the stack of drivers.  I noticed in VirtualBox that its default network interface was a host-only adapter (file / preferences / network) but it does support virtual NAT and Bridged networking option, very similar to VMWare.

Sure enough a new VirtualBox Host-Only Network connection showed up in my list of network connections, and each of my real network connections (Wireless and Gigabit Ethernet) included a new driver which was enabled and named VirtualBox Bridged Networking Driver.  I noticed that it did not try to add the driver to my VPN connections and while this driver was on the list in the Bluetooth networking connection, its check box was not enabled.  From a CMD prompt, IPConfig /all shows a list of  network adapters that is nearly 100 lines long now.  With all the IPv6 stuff the list was over 80 lines long before VirtualBox was installed, so yes it's one more adapter, but it's just one in a long list.  We're not in Windows 3.1 any more, baby!

A First Test: Ubuntu
I decided to set up an Ubuntu VM first.  I downloaded the latest version of Ubuntu and found something else to work on for about 20 minutes while the 680MB ISO image downloaded...

I then created a new VM in VirtualBox by clicking the New button and selecting the Linux Ubuntu OS from the menus that followed.  I used the defaults of 384kb of RAM and 8GB for the boot drive (that sounds awfully large to me but I decided to use the defaults.)  When I clicked the Start button to start the machine it took me into a First Run Wizard which walked me through setting up the install process to boot from the ISO image I downloaded and begin the Ubuntu installation.  There was no need to burn the image to a CD and then boot from the CD in the VM; that would just be dumb.  When selecting the drive to use there is an icon to the right which takes you into the Virtual Media Manager and allows you to point to an ISO image and treat it like a CD drive.

Once the installation started, VirtualBox complained a bit that the display mode was only 16-bit and not 32-bit but that was only because of the Ubuntu install process and the notice messages that appeared could be ignored.  The ISO image was read and it did a quick virtual boot to itself, resulting in an Ubuntu GUI screen with an icon to Install Ubuntu.  I double-clicked the icon (after seeing a message about how the keyboard and mouse clicks get captured, and clicking 'do not show again' then continuing.)  This launched the actual Ubuntu install process.  After answering a few basic prompts for my user name and what to call the computer (the VM that is) the standard Ubuntu installation took place.  This took a bit of time, but when it was done it prompted to reboot.

The first reboot prompted to remove the CD and then press Enter.  I had read that the First Run Wizard would automatically unmount the ISO image after the install was complete so I didn't have to do anything but just press Enter and my Ubuntu VM booted up.  This was fairly straight forward.  After a bit Ubuntu prompted to download and install patches & updates (158MB of them, 227 packages!) and I let it do that.  It had correctly found its way to the network through VirtualBox's virtual NAT driver so that was working great.

While it was doing that I poked around a bit to find out how to install the VirtualBox additions.  Every VM technology I have used has additional hooks that should be installed on the guest OS to help improve performance and functionality in a virtualized environment.  On the VirtualBox menu for the guest machine (top of the window, Devices menu) I noticed an 'Install Guest Additions...' menu item and I assume that's what I should do, at least without reading any documentation.  But first I will wait until those 227 updated packages get done being installed!

Once the updates were complete and Ubuntu prompted to reboot then I logged in and proceeded with installing the guest additions.  When I clicked that option, Ubuntu displayed the prompt in the image at the right.  I clicked OK and then opened the VboxAdditions_3 CD image.  The autorun process did not execute on its own so I ran autorun.sh and provided my admin credentials.  This script installed the VirtualBox additions for Ubuntu.  When it completed it prompted that they would take effect upon the next restart so I restarted Ubuntu.  After that the integration of the keyboard and mouse worked seamlessly with the VM and other applications running on Win7.

If I get around to installing other distros or Windows VMs I will post my findings with those as well.