How To Love Linux On The Desktop

computer operating system Linux

Test Center staff have found a number of good reasons for removing a Linux distro entirely and doing a clean install. For testing and evaluation purposes, however, it's helpful to have multiple systems available simultaneously for comparison. This is where virtual machines really come in handy.

VMware Corp., Palo Alto, Calif., has dominated headlines with its VMware Server, but there are plenty of other vendors with various flavors of VM software, including Microsoft's HyperVisor.

Be Patient
Creating virtual machines on a Linux host system can be frustrating. Installing VMware Server on a Linux box to run multiple Linux distributions was difficult enough that it was preferable to install VMware on a Windows machine and run multiple Linux virtual machines instead. For this system builder recipe, virtual machines were created in Linux using open-source QEMU, a free application from French computer programmer Fabrice Bellard.

A command-line application, QEMU, is a fast processor emulator and virtualizer. Currently, the package supports ARM, PowerPC, SPARC and x86 emulation. While we missed the easy point-and-click interface that comes with Windows packages, creating virtual machines was a less aggravating process. Using QEMU, virtual machines for Fedora, CentOS, Gentoo, Mandriva and PuppyLinux were created on top of the Ubuntu host.

id
unit-1659132512259
type
Sponsored post

While many modern Linux distributions have QEMU preinstalled, Ubuntu did not. It was simple enough to download and install using Ubuntu's package manager; the latest source is also always available from fabrice.bellard.free.fr.

Emulation and virtualization are, at heart, two different things. An emulator pretends to be a different machine or to have a different hardware configuration from the host. Fabrice's Web site lists all the processors that QEMU can emulate, as well as prebuilt images of various operating systems available for download. However, performance is not all that great.

Virtualization, on the other hand, actually executes code on the system processor instead of mimicking the processor. As a result, the virtualizer has better performance than the emulator. QEMU offers software virtualization, not hardware virtualization.

On this Ubuntu host, QEMU was located in /usr/bin. Here are five tips to help you get from A to B:

Next: Tip 1: Creating The Virtual Machine Tip 1: Creating The Virtual Machine
The Test Center first had to define a virtual hard disk on the system to hold the Fedora ISO that was downloaded. This was done using the qemu-img command, which creates a raw format disk image by default with 256 MB of memory: $ qemu-img create 256M.

At this point, the virtual machine is an empty file on the host machine and has no operating system running on it.

Tip 2: Installing An OS On The Virtual Machine
The next step is to use an ISO image to boot up the virtual machine: $ qemu -cdrom -hda -m 256 -boot d.

The -cdrom parameter lists where the ISO image file is located on the host system. Despite the name of the parameter, the ISO does not need to be on a physical CD or in the CD-ROM. The -hda parameter defines the path to the virtual hard disk that was created using the qemu-img command. The -m switch allocated memory to the virtual machine, in this case, only 256 MB of RAM (Fedora 7 does fine with this). The -boot parameter assigns a drive letter to the ISO image.

The virtual machine will see two drives; the -hda flag refers to the primary master and the -cdrom flag refers to the secondary master. From the host system's point of view, these drives are still two files while the virtual machine treats them as real drives.

If the virtual machine had been created correctly in the previous step and the ISO file is valid, a window will open. After going through the bootup sequence, the contents of the ISO—whether it's an installer or a Live Desktop—will appear.

For all intents and purposes, the software running in the window thinks this is a real machine. So the installation can be launched by clicking on the installer on the desktop and proceeding as normal. If the install needs to reboot, that's fine, as rebooting the virtual machine won't shut down QEMU. Once the installation is complete, it's safe to shut down the virtual machine and QEMU.

Clicking anywhere inside the QEMU session window captures the mouse for the virtual machine. To release the mouse to work on the host machine, press Ctl-Alt. The Ctl-Alt-F command toggles the QEMU session between normal and full-screen mode.

Next: Tip 3: Starting Up The Virtual Machine Tip 3: Starting Up The Virtual Machine
The previous step ran the ISO image on the virtual machine, not the installation that just wrote the operation system to the virtual machine file. The following command opens up the virtual machine in QEMU with the installed operating system.

There are other options available when starting the virtual machine, such as adding the -soundhw sb16 option to simulate a SoundBlaster 16 card; the -std-vga option to simulate a standard VGA card; or -localtime option in case the host OS is not using GMT for its clock. Networking is enabled by default, and QEMU obtains an IP address from the DHCP server automatically.

The virtual drive can be edited to increase the amount of memory used.

None of the QEMU commands are too complicated or difficult to type, but there are many qemu parameters for the network, USB, file-sharing and I/O devices. A quick glance through the QEMU page lists them all and suggests many possible ways for using them. Typing qemu at the prompt without any parameters will also list some possible parameters.

Tip 4: GUI Options
There are several graphical tools that simplify QEMU's advanced features. QEMU Launcher and QEMUlator are just two of the many options. QEMU Launcher is available from https://gna.org/projects/qemulaunch. The QEMUlator is available from http://qemulator.createweb.de/.

First, QEMU Launcher organizes its various features under three tabs: Configurations, Launcher Settings and About. Under the Configuration tab, virtual machines are created using existing QEMU images. All that was needed was the name of the configuration being created, the location of the virtual drive (created by qemu-img) and memory to be allocated. After creation, the new virtual machine can be launched directly from the interface.

Even running qemu-img is unnecessary, as a brand-new virtual machine image can be created via the New button next to the hard-disk 0 label. The pop-up dialog will accept all the required information to create the virtual drive, as well as assigning the CD-ROM to boot up from the ISO image. Even though qemu-img command is straightforward, the Launcher makes this step even simpler.

Through the Launcher, the virtual machines can be configured to work with the network card, an alternate video device, set the clock or turn on system sounds. There are also options providing access to a Samba share.

QEMUlator is even more powerful than QEMU Launcher. It can create brand-new disk images, install distributions and monitor running virtual machines. QEMUlator has an Install Wizard that steps through the process of installing another distribution. The wizard is launched by clicking on System from the menu bar and selecting "Install system."

Under QEMUlator, running the virtual machine with the actual installed distribution is as simple as clicking the run arrow at the top of the screen. All existing virtual machines are listed under the My Machines tab and can be modified with the Show Settings button. QEMUlator also lists all running virtual machines in one place. The Show option for each virtual machine displays the exact qemu command with all the parameters that are being run. This is handy for scripting purposes, when the interface is not useful.

Tip 5: Boosting For Better Performance
The virtual machine can be modified to run with more memory on the fly by increasing allocated memory when starting QEMU. For a greater performance boost, QEMU Accelerator, available on http://fabrice.bellard.free.fr/qemu/kqemu-doc.html can be installed.

Even though the machines are virtual, they use their share of real system resources, such as processor power and memory. The more pumped up the host machine's hardware is, the easier it will be to run multiple virtual machines.