Cooking with Linux – Still Searching for the Ultimate Linux Distro?

by Marcel Gagné
This article originally appeared in the September 2007 issue of Linux Journal.

Why does a person install one Linux, then another, and then yet another? Because a person can, of course! Such is the nature of choice, and Linux gives you a choice . . . and what a selection.

What distribution are you loading up today, François? MCNLive? Very nice, and compact, too. When you get a chance, you should copy it to your USB key. That way you can always carry a live Linux distribution with you. Quoi? You’re not sure if this is the one. I see. Yesterday, you were running OpenSUSE 10.2, and the day before you installed both Debian Etch in the morning and Kubuntu Feisty in the afternoon. Last week, you managed Fedora Core 7, CentOS 5, Mandriva Corporate Desktop 4.0, Slackware Linux 12, and a half dozen others. Are you having trouble finding something you like? You like them all but you just can’t choose, eh?

Well, mon ami, I hate to interrupt this voyage of discovery, but I need that wine list I sent you a couple of days ago. What do you mean, you don’t have it? It was on the machine you are installing and you erased the disk . . . you know, François, there are better ways to try out all these distributions. For the moment, leave what you are doing and head down to the wine cellar. I can see our guests approaching the restaurant now and they will be here any second. Bring back the George du Beouf Cuvée Saint Valentin from the East wing. There are three cases right next to that old suit of armor you brought in last year. Vite!

Welcome, everyone,to Restaurant Chez Marcel, where fine wine meets great Linux and open source software. Please sit down and make yourselves comfortable. I’ve already sent my faithful waiter on a quest to retrieve the perfect wine for tonight’s menu. While we wait, I’m going to introduce you to an impressive parade of Linux distributions, courtesy of system virtualization. Best of all, you can keep running your current system while you take these others out for a spin.

Ah, glad to have you back, François. Please, pour for our guests while I introduce the first item on tonight’s menu.

Fabrice Bellard’s QEMU is a free, open source, machine emulator and virtualizer. The reason for this distinction is that QEMU can emulate different machine types and hardware but the performance, while not bad, can be greatly improved upon. Virtualization is achieved by using a kernel module that executes code on your system processor rather than emulating the processor. Another reason why this is an important distinction to make is that QEMU can also emulate different processor architectures. For instance, if you wanted to run a SPARC or a PowerPC machine on your Intel processor, you could. Fabrice’s Website has a nice table showing the various processors that can be emulated. There are also some pre-built QEMU images of different operating systems, ready for download — you can even get FREEDOS and Minix if you like. What we’re going to do, though, is install Linux, lots and lots of Linux distributions.

Most modern Linux distributions come with QEMU but the latest source is always available from fabrice.bellard.free.fr. The virtualization kernel module, however, usually requires that you download it from the site and build it yourself. While you don’t specifically need it, the performance improvements are dramatic and well worth the effort. Since this is a kernel module, you load it with the modprobe kqemu command.

Let’s take a look at how QEMU works. For this first demonstration, I’m going to install Puppy Linux from an ISO image downloaded from the Puppy Linux Website. Since Puppy is a cute little distribution with minimal space requirements, I’m going to create a relatively small disk image (a virtual hard disk) for it to live in. This is done with the qemu-img command.

     qemu-img create puppy216.img 256M

The above command creates a raw format disk image by default. There are a few different image formats, most notably qcow2, which is a more portably image format, useful if you want to install that other OS; you know, the one from Redmond. Our next step is to install Linux into this disk image, which I do using this [cw]qemu[ecw] command.

     qemu -cdrom ../isos/puppy-2.16.1-seamonkey-fulldrivers.iso \
        -hda ./puppy216.img -m 256 -boot d 

Several interesting things are happening here and I’ll describe each one briefly. For starters, the -cdrom parameter is, in fact, the path to the CDROM image from which you are installing your distribution. If you were using a physical CDROM, that path would likely be something like /dev/cdrom. The next parameter, [cw]-hda[ecw], defines the path to the disk image we just created. This is followed by the [cw]-m[ecw] switch which, in this case, allocates 256 Megabytes of RAM to the running session. Finally, we have the -boot which identifies the boot drive (our CD image), the so-called D drive. As soon as I press Enter, the Puppy Linux install starts (see Figure 1).


Figure 1: QEMU boots a Puppy!

Note: To see the full size screenshots, click on the images.

From here, you simple follow the steps for a Puppy Linux installation, or that of whatever distribution you are installing. Before I show you the result, there is one other parameter I’d like to share with you and it’s the -std-vga paramater. This tells QEMU to simulate a standard VGA card with BOCHS extensions. You can also use the -localtime parameter to tell QEMU to run your session using the local machine time as opposed to the default UTC. Remember the kernel acceleration? Try using the -kernel-kqemu. This is just a small sample. There are network parameters, USB parameters, file sharing parameters (SMB), devices parameters, and more. You are only seeing the basics so make sure you check out the man page for the qemu command. Remember, also that my settings for this example imply a very small footprint distribution. To run something slightly larger, such as MCNLive (a great live distribution based on Mandriva), I would create a larger disk image (see Figure 2 for a shot MCNLive in action).


Figure 2: A lovely graphical desktop, courtesy of MCNLive and QEMU.

When you start working in a QEMU session for the first time, you may find yourself wondering why you can’t mouse out of the session and this, is the first and most important lesson you will learn about QEMU keyboarding. Once you click in a QEMU session, it takes control of your mouse. Ctrl+Alt releases the control so that you can work on your master system. To return to the QEMU session, just click anywhere on the window. The second most important keyboard command is Ctrl+Alt+f which switches to and from full screen mode.

Now, both Puppy Linux and MCNLive.org are live distributions but both offer an install icon on the desktop. Once a distribution is installed, starting the session is a little different, mostly because you won’t be booting from the CDROM ISO image. In this example, I simple identify my hard disk image for qemu and select the amount of RAM I want to use.

     qemu -hda ./mcnlive.img -m 384

All this working at the command line is easy enough, but there are dozens of [cw]qemu[ecw] command parameters, not to mention tons of possible options or combinations of those. That’s why we are going to look at some great, graphical tools, for working with QEMU, starting with Erik Meitner and Linas Žvirblis’ Qemu Launcher.

Qemu Launcher provides a front end to basic as well as advanced features of the QEMU command suite. There are three tabs labeled Configutations, Launcher Settings, and About. Most of the action takes place under the first tab. For starters, you can create a set of configurations based on existing QEMU images just by entering a configuration name, a file location for your hard disk (the image created by qemu-img), and defining the memory you wish to allocate. Click the Save button and you are ready to start your virtual machine by clicking the Launch button on the lower right of the Qemu Launcher interface. In Figure 3, I’ve added a profile for Debian Etch 4.0 to launch with 384 Meg of RAM.


Figure 3: Adding an existing QEMU image under Qemu Launcher is easy.

I entered the path to the Debian Etch image, but I could also have clicked the New button next to the “Hard disk 0” label and created an image using the popup dialog. My next step would have been to click the “Use CD-ROM” check box, select CD-ROM from the Boot disk drop down list, and continue normally from here. As you can see, the Configurations tab is also a multi-tabbed affair which allows you access to other QEMU settings. Under Linux boot, you can specify an alternate kernel image or pass kernel parameters. The Network tab offers control over your network card (the default is to use a pass through to your main system) as well as providing access to a Samba share, useful should you want to run Windows. From the Hardware tab, you can choose an alternate video device, set the clock, define your hardware, or turn on system sounds to name a few. Finally, the Emulator tab gives you control over the QEMU session itself.

Incidentally, a recent alternative to QEMU is KVM, the Kernel Virtual Machine, which works by taking advantage of processor-based hardware virtualization technology. On the Intel platform, this is known as VT which AMD processors call their hardware virtualization, Pacifica. What it means to you is that you can take advantage of Linux KVM to run your virtual machines with substantially better performance than you can with straight software virtualization. The catch, as you might expect, is that not every machine out there supports hardware virtualization. To find out whether your system is a candidate, execute this little snippet of code from a terminal window or shell.

     grep -E '^flags.*(vmx|svm)' /proc/cpuinfo

If you see the string vmx or svm returned, then your processor is ready. If not, you’ll have to stick with the software based virtualization provided by QEMU. The kvm commands are pretty much interchangeable with those of qemu as are the install and operating system images. In fact, KVM is based on QEMU.

François, I see a number of empty, or nearly empty, glasses out there. Please, make sure everyone is well satisfied.

The next item on tonight’s menu isn’t as sophisticated or flexible (you can’t create images), but those of you with a soft spot for Ruby may want to check out Mathieu Mast’s Qemu Supervisor, a front end based on, you guessed it, the Ruby programming language. Aside from Ruby itself, you’ll also need to have the Ruby GTK2 bindings, the libgtk2-ruby package and its dependencies. Once these prerequisites are met, it’s just a matter of extracting the Qemu Supervisor source and running a make install from the source directory. To run the program, execute the command, qemu-supervisor. From the interface that appears (see Figure 4), you can choose to add QEMU images for launch.


Figure 4: Now you can Ruby-up your QEMU sessions with Qemu Supervisor.

The final item on tonight’s menu, Rainer Haage’s Qemulator, is a must-see stop on your search for the ultimate QEMU front end to all your ultimate Linux (virtual) boxes. This impressive and feature-rich application covers pretty much every aspect of QEMU’s operation. This involves creating disk images (see Figure 5), installing distributions, monitoring running instances, and so much more.


Figure 5: Qemulator makes QEMU easy with tools for image creation, and more.

Like the other programs featured here, Qemulator provides easy access to existing QEMU images. Click the Plus sign at the top of the main window, enter the basics, and save. To run a virtual machine, just click the run arrow at the top right. The main window lists existing images under the “My Machines” tab. Each of these machines can, in turn, be configured or changed by clicking the “Show Settings” button at the bottom of the main window (see Figure 6). The tabbed view provides access to image settings, disks and other hardware, network settings and more. Several machines can run simultaneously (given adequate resources) with access to each under the Running Jobs tab.


Figure 6: Easy access to all QEMU settings are a click away.

There are some nice, somewhat hidden feature as well. For instance, right click on a machine in the “My Machines” list and a small popup menu will appear. From that menu, you can select “Show commanline”, perfect for the curious who want to find out exactly what the qemu command is doing once you’ve tweaked all those settings. From that same menu, you can get information on the image itself, changes settings, and more.

To round things out, Qemulator even provides an Install Wizard to take you through the steps of loading up yet another distribution. Just click System on the menu bar and select “Install system”.

Looking around the restaurant floor, I see that many of you are already discovering a downside of running all these virtual machines. Virtual or not, each instance of Linux (or whatever else) that you run, requires processor time and system memory. The more VMs you choose to run, the more resources you will be drawing on. I run a second distribution happily on my dual-core notebook, but a third is pretty much out of the question for this machine. The more resources you can provide, the faster your virtual machines will run and the more virtual machines you can run.

Ah, if only we could find some way to run multiple instances of our award-winning wine cellar. But then, François and I might not have the pleasure of sharing ours with you, mes amis. And now, sadly, the time has arrived and we must now head back to our non-virtual homes. However, we here at Chez Marcel would never dream of sending you off without a final glass of wine. François, please take a moment to refill our guests’ glasses a final time. Raise your glasses, mes amis, and let us all drink to one another’s health.

A votre santé! Bon appétit!

Resources

QEMU Website

Qemu Launcher

Qemulator

Qemu Supervisor

Facebook Comments Box

Leave a Reply

Your email address will not be published. Required fields are marked *