Linux in a Virtual Machine

I own a Macbook on which I’ve been running Linux 99% of the time for over a year now. Although a Macbook is not necessarily the best choice to run Linux, I made that decision because installing Linux on a Macbook is very well documented. However, as far as you can get, it’s always difficult to get a configuration you are 100% happy with (no subwoofer support, flaky suspend…). With recent advances in virtualization technologies, both in software and hardware, I’ve been willing to test running Linux and Windows (the guest OSes) inside Mac OS X (the host OS).

Feature set

Here are some of the features you can expect from virtualization software.

- Near-native speed: thanks to recent hardware support for virtualization, it’s now possible to run a x86-based guest OS inside a host x86 OS at considerably reduced speed penalty. As a result, the guest OS is perfectly comfortable to use. See X86 virtualization.

- Hardware emulation: in order to run unmodified guest OSes, virtual machines emulate hardware for which most of the OSes have drivers. As a result, it’s very easy to install the guest OS because the hardware emulated is standard. The virtual machine can be seen has an abstraction layer between the actual hardware and the guest OS.

- Growing-size hard disk: while it’s usually possible to boot directly from a disk partition, most of the virtualization softwares support growing-size file disks. Those files contain the contents of the emulated hard disk and are able to grow dynamically in size. If you allocated 32 GB to your virtual hard disk but it only contains 8 GB so far, the guest OS will see a 32 GB disk available but it will only take 8 GB on the actual hard disk.

Personally, I have a partition for Windows on my Macbook but I used it only once to release Fantasdic for Windows. With their dynamically growing file disk, virtual machines would have allowed me to gain a lot of space. Some softwares like QEMU support compressed disk files, to gain even more space.

- NAT: this allows to transfer network traffic from and to the virtual machine. Whether you’re connected to Internet through Ethernet, Wifi or 3G, for the guest OS, this is the same. It only sees an Ethernet network card and you can connect to Internet from the guest OS transparently. However, this also has some drawbacks because you wouldn’t be able to run software that directly needs the Wifi card (e.g. network scanner).

- Bridge networking or Host interface networking: this allows your virtual machines to have their own IP address in your local network. If you install the Apache HTTP server in your Linux virtual machine, you can access it from Mac OS X or any other computer on the local network. This also allows me to ssh into my Nokia internet tablet or copy files to it.

Although most virtualization software have built-in convenience support for shared folders, bridge networking allows you to share folders across virtual machines and even real machines over Samba or SSH.

- USB: if you plug USB devices in your computer, they can be redirected at will to the virtual machine.

- CD Rom: you can redirect your real CD Rom to the virtual machine or select an .iso image and it will be seen as a CD Rom from the virtual machine.

- Seamless integration in the host OS: seamless mouse pointer integration, copy-paste between host and guest OS…

- 3D acceleration: although I don’t play games on computers, this may be of interest for some people.

Parallels Desktop and Vmware Fusion

The first thing I did was to try out the trial version of commercial products Parallels Desktop and Vmware Fusion. Both work well, are easy to use, are highly-integrated in Mac OS X and share a fair amount of features. Both cost $79.99. I didn’t test them in full depth but from what I saw, it would be difficult for me to choose one between those two if had to.

I digress but I was the witness of a shameless commercial practice at Parallels Desktop. Since my browser is in French, it was automatically redirected to the French version of Parallels Desktop’s webiste and the software was priced 79.99 euros. However, if you go to the English version, the software costs 79.99 dollars. That is 56.98 euros… Is that the cost of localization?!

QEMU

I got all excited about virtualization but not to the point of paying this prohibitive price so I started to have a look at open-source solutions. I tried out Q, which is a Mac OS X port of QEMU. QEMU does more than Parallels Desktop and Vmware Fusion. It allows to run a guest OS for a processor architecture inside a host OS with another processor architecture. It’s thus also a processor emulator.

Although it worked well, Q was terribly slow. While looking for acceleration extensions for QEMU, I found QVM86 but Wikipedia mentions that the developer ceased development when VirtualBox was released so I quickly switched to trying out VirtualBox.

VirtualBox

VirtualBox was THE pleasant surprise of all the software I tested. It’s free, it’s open-source, it’s easy to use, it’s well integrated in Mac OS X. Of all the feature set mentioned above, VirtualBox has everything. I’m simply amazed by this software.

A limited set of components such as USB support are closed-source. This means that if you install VirtualBox on a Linux host using the distribution package, you get the open-source edition, which misses some features. However, it is always possible to download the binaries from the official website and install them by hand.

VirtualBox was originally developed by German company innotek. However, the company has been acquired by Sun in February 2008. Also note that VirtualBox includes code from QEMU.

Maemo development

I wanted to check whether VirtualBox could be used for Maemo development or not. Since the Maemo SDK itself relies on virtualization software (QEMU) to emulate the ARMEL architecture, my concern was that running virtualization software inside virtualization software may not work well or be too slow.

I installed Scratchbox and the Maemo SDK inside my Linux virtual machine and it turned out that my concerns were not justified. The SDK works well and is very responsive, even when running graphical applications with Xephyr.

As mentioned before, Bridge networking allowed me to ssh into my tablet and copy files to it with scp, from the virtual machine. While the USB is correctly redirected to the virtual machine when the tablet is in USB mass storage mode, I was unable to get USB networking working because Mac OS X intercepts/detects the network connection.

I think VirtualBox is a good solution for Mac OS X users willing to develop Maemo applications.

4 Responses to “Linux in a Virtual Machine”

  1. timsamoff Says:

    I run Ubuntu (and others) in Parallels without a hitch. It’s even better with Parallels Tools installed (full screen resolution, auto mouse detections, etc.). I highly recommend Parallels (even for the price) and it’s nice not having to restart my machine (e.g., with BootCamp) in order to run multiple VMs over OS X.

  2. Mathieu Says:

    > It’s even better with Parallels Tools installed (full screen resolution, auto mouse detections, etc.).

    Same with VirtualBox when you install the “guest additions”.

  3. Gerard Braad Says:

    I personally do all my development from within Virtual Machines. I have used VMware workstation since almost it first release… so I still use VMware (although Xen, Virtualbox and KVM are becoming very promising). From server on the servers and workstation (and fusion) and notebooks and desktop systems. I have neveer had the feeling it was unresponsive, expect for using it on a netburst P4 (at work) for some time. Desides that, it is an excellent way to be more productive. It is easier to test and develop your software, since you can have a clean sandbox. the only time it can be a little pain in the ass, is when you need to do closer to hardware tests (like performance related or graphical). I sometimes use OpenGL and for this I do strongly advise to do it natively (until this gets ‘better’ supported too). Also when you really want to emulate an ARM, try to do it outside of the virtual machine, since it does give an additional overhead… although for Maemo I also keep it inside the VM. For more real ARM testing, like with the Mojo distribution, I used QEmu outside of a VM…

  4. Murphy Says:

    For speeding QEMU, I use KVM (http://kvm.qumranet.com/kvmwiki/Front_Page) which uses hardware virtualization.

Leave a Reply

CAPTCHA Image