Virtually yours with Virtualbox

While virtualization isn’t a new technology, I haven’t had time or a specific need to mess with it until recently. Since I’m always on the lookout for open source solutions, I found that a fairly robust software package from Sun (you may know them from their only slightly more popular Java software) called Virtualbox was available for install in Ubuntu through the Synaptic package manager. Virtualbox is just about as easy to install in Windows and OS X if you use their binary packages which are also free, but don’t come with sourcecode. The open source edition (OSE) doesn’t have support for USB, only offers a virtual IDE controller (a faster virtual SATA is available in the closed source binaries), and doesn’t allow for remote desktop access to the virtual machine [edit: I found this is working fine in 1.5.6 OSE] – but Sun hopes these features are more important to business users and will allow them some amount of revenue from companies that need to develop with those available. I’ve been trying out Virtualbox on Mac and Ubuntu mainly and my experience so far has been great.

I own a couple pieces of Windows software for which I haven’t been able to find open source alternatives. This has pretty well sucked for me as a Mac user since it means I have to either reboot my Mac into Windows or run some kind of virtualization software (like Virtualbox or Parallels) to run a “virtual machine”, and install Windows in it. Since I’ve felt both of these options were not optimal, I have just done without that software for some time. Recently we’ve been developing some Windows software at work and it was my task to provide a test machine that R&D could use to test deployment on. There was no way I was going to re-image the machine after every install, so it was time to check this virtualization thing out.

Virtualbox lets you create a virtual machine that resides on a portion of your hard drive (or a removeable drive), and configure the amount of memory that will be available to it. You can choose whether to mount a CD in the virtual CD drive at boot time (which is how you load an OS on your virtual machine). Once you have an OS (in my case I loaded up a slipstreamed WinXP sp2 disk), it runs pretty quick – very useable. Of course, you don’t have to load up windows in this box – you could easily use Virtualbox to test out any of a zillion different distros of Linux on your Windows host if you’d rather. But I was able to run my Windows software on my Mac without a hitch.

My Mac has a funky wide screen screen res, and at first I couldn’t get Windows to look right in Full Screen mode (Apple F), but then I discovered that one of the menu items allows you to install some Virtualbox “additions” which basically loads up alternate video drivers specific to your video card (I’m assuming) which get installed into your guest OS. After that simple install, I could resize the window at will and go full (wide) screen at will.

Then I wanted to do more or course. What if I messed up this virtual machine? How do I back it up? I discovered the joys (and pains) of Virtualbox snapshots through trial and error. If you take a snapshot of a machine at some point, it makes it easy to revert back to a prior point – perhaps before you installed that last software which corrupted everything. However, snapshots are a little tricky in Virtualbox and you can easily delete changes you’ve made to the OS that you wanted to keep if you aren’t careful. Deleting a snapshot in the right order will merge changes into the current machine (the .vdi file), so if you use snapshots read up on it. Backing up was simple enough – simply copy the .vdi file (this is big but not as big as the full hard drive you allotted for the virtual machine) to DVD or a spare area of your drive. You can even copy it to another PC and run it in another installation of Virtualbox if you make sure that the hardware settings are exactly the same (memory size, controller type, and in the case of Windows – the MAC address to avoid activation issues if you don’t have a volume license key). I managed to do this successfully (back up the machine and transfer it to a PC running Linux and run it) when I realized that act was probably breaking the license agreement for Windows as well as the software I had installed. I hate licensing BS which is the main reason I look for open alternatives. I can see why Microsoft has been losing a lot of market share lately, and I would guess that this virtualization business probably has their lawyer’s panties in a serious knot.

It wasn’t until I started doing some testing at work when I ran into a snag. We have a Windows domain at work, and my Virtualbox setup there (on a Linux machine) wasn’t able to use any kind of network connection other than the default NAT setup. I realize now that I may have to set up a static bridged interface on the linux host so that I can join the virtual machine to that domain. While it’s not necessary for the basic software testing I have to do soon, it is definitely a hurdle for me before I can think about using virtualization for more tasks.

[ed. 1/30/09: Solved this one by installing uml-utils and bridge-utils and running a script to bridge a new virtual network interface called tap1 over to my real eth0 interface. Then I could switch from NAT to host interface (by entering tap1 in the interface name) and join the domain fine. Script provided below.]

#!/bin/bash
sudo tunctl -t tap1 -u myusername
sudo brctl addbr br0
sudo ifconfig eth0 0.0.0.0 promisc
sudo brctl addif br0 eth0
sudo dhclient br0
sudo brctl addif br0 tap1
sudo brctl addif br0 tap1
sudo ifconfig tap1 up

  • http://www.nprophet.com NP

    Cool idea. If I had a gigantic hard disk I think I’d do something like this on my mac just for fun.

    How does the execution speed compare? Do things fall apart if two OS’s have to share something like a graphics card running two OpenGL applications simultaneously?

  • http://www.in8sworld.net Nate

    Virtualbox gets a lot of praise for being fast (though lacking in some of the features found in VMware). Here’s a quick measure: XP Pro sp2 fully loads in 36 seconds in the VM on my 13.3″ macbook. Firefox 3 loads up in the VM in 6 seconds. I’d say it feels a tad less responsive than OS X does which is to be expected.

    I went through the OpenGL apps list and found only three programs that I use on the entire list: Google Earth, Stellarium, and Warcraft III. I don’t have any of those installed in the VM since I really only need it right now for a single Windows app I own called Army Builder, and I can’t think of a situation where I would really need to run any of the above three in the VM *and* at the same time as running one of the others natively – so I won’t be doing any crash testing for you ;) I notice Blender is OpenGL, so perhaps you could try it and report back.


This page was created in 1.449 seconds.