Wednesday, August 13, 2008

Virtualize your operating system with qemu

QEMU is a processor emulator, it allows you to run variety of unmodified guest operating systems such as Linux, Windows, Solaris, Dos etc just like Vmware and VirtualBox. In fact VirtualBox dynamic recompiler are based on QEMU. QEMU supports emulating several hardware platforms, including x86, AMD64, Alpha, MIPS, ARM, PPC, SPARC etc.

QEMU comes with command line interface, where you pass your configurations by parameters, but there are 3rd party GUI front end, such as Qemulator and Qemu-Launcher. To improves the performance of QEMU, we needs either KQEMU kernel module or KVM. Both of them are accelerator that to increase the execution speed of QEMU.

In this post, I covers installation of QEMU as well as KQEMU. As well as simple example of the use of QEMU command lines, how to create image files that allows to execute by both QEMU as well as Vmware.


I believes that you may download QEMU from your repository, which it may already comes with kqemu. You may also manually compile both qemu and kqemu. My Linux distro repository contains older version of qemu, therefore I choose to compile qemu and kqemu myself.

You can download both qemu and kqemu from

Compilation and Installation for qemu and kqemu are straight forward. You just need to do the steps below:

1. untar the archive.

2. compile


3. install using root permission

make install

kqemu is a kernel object, it may not auto reboot every time you reboot your machines, check out the kqemu installation for Linux HERE.

To manually load kqemu, do this in root:

mknod /dev/kqemu c 250 0
chmod 666 /dev/kqemu
/sbin/modprobe kqemu

Boot up live cd using QEMU

To check out the Live CD iso without have to burn it to CD, i usually use qemu. For this I really appreciate the flexibility of command line interface, without much clicks here and there, I boot up my Live CD with a single line of command.

For this illustration, I choose Myrinix. Myrinix is a multi purpose Portable Linux based on Debian SID. it can be in Live CD format ,USB drive as well as install in windows xp ntfs partition without modify the Master Boot Record (MBR). Myrinix also supply a series of application module that can be easily added later. You may download the latest Myrinix Live CD iso from HERE.

Lets boot up the Live CD ISO now!

qemu -cdrom myrinix-kde-200808.iso -m 512 -boot d

Short and simple! Specified your iso file path at -cdrom, in case you want to load up the Live CD from the physical CD, you may change to -cdrom /dev/cdrom ( depends on your cdrom dev). -m 512 is to force qemu to use 512Mb on RAM, by default qemu uses only 128Mb. At last -boot d option indicates that I want qemu to boot up from cdrom.

Verify kqemu is loaded

During loading the Live CD, you can verify whether kqemu is it loaded and in use. Press Ctrl+Alt 2, and type:

info kqemu
kqemu support: enabled for user mode

As long as I see the positive message, kqemu is successfully loaded and in used. Press Ctrl+Alt 1 to goes back the emulator screen.

Connects to the Internet in guest OS

By default, qemu will act as dhcp server and support internet sharing from your Host machine. Therefore as long as my host have internet access, my guest OS in qemu may have internet access too.

Myrinix does not acquire IP from DHCP by default, I think a lots of Linux Live CD doesn’t do that too. Therefore I have to do it manually. Login to root and run dhclient on eth0.

su -
dhclient eth0

Connects to Host Machines

I can obtain virtual IP for internet sharing from by default, the same way I may also connect to my host machine by this IP.

ssh mysurface@

If my guest Linux have KDE installed, I may use fish in Konqueror for file transferring from my host machine to my current guest Linux. Check out how to do that at HERE.

Qemu provides more options, just type qemu, you will get a full list of options it support, check out the user document for more details information.

Install a guest OS

To install a guest OS using qemu, first thing I need to do is to create an image file using qemu-img. qemu-img support various of file format including vmdk. qemu support loading vmdk image files. Vmware image file is in vmdk format. Bare in mind, load up vmdk files created by vmware at YOUR OWN RISK. (I have a bad experience on loading up Red Hat ES4 vmdk created by vmware server, which it fails to boot up X after booting it up by qemu. My guess is both qemu and vmware emulates different set of hardware drivers. Well, at last I manage to fix it by reinstall vmware tools in Red Hat ES4.)

To create a 10G disk image in vmdk format using qemu-img like this: (Don’t worry, 10G disk image do not actually eats 10G of your physical Hard disk space)

qemu-img create -f vmdk myos.vmdk 10G

Now I may load up your installer CD with disk image with qemu like this:

qemu -hda myos.vmdk -cdrom myrinix-kde-200808.iso -m 512 -boot d

After I have done the installation, I will boot up my guest OS from disk image like this:

( You may want to point your cdrom to physical cdrom as well as enable USB.)

qemu -hda myos.vmdk -cdrom /dev/cdrom -m 512 -usb -boot c

qemu-img allows me to convert disk image too, in case I have downloaded image disk from somewhere, I can convert it to vmdk like this:

qemu-img convert -f qcow freebsd.qcow -O freebsd.vmdk

To load up image disk with vmware, I need another file, with extension of .vmx. Vmx file is a text file that contains configuration for your disk image. To generate one using Remember to point your disk image to ide0:0.filename in vmx, for example my case:

ide0:0.fileName = "freebsd.vmdk"


It seems even with kqemu, qemu performance in terms of execution speed is still slower than vmware. I compare the same disk image in both vmware server as well as qemu. It will be obvious when I access the GUI menu in my guest OS.

There are still a lots of options and tips I fails to covers here, in case you have any tips, please feel no hesitate to leave me comments.

Related Posts
Help yourself in python
If your computer science student, you study IT, click with technology, python is not a snake for you. It is a scripting-...

How to generate system hardware profile for your laptop?
Recently, MIS department request us for hardware and software profile. They provide us Belarc Advisor (personal pc audit...

How to increase your linux system loading speed
Linux can be run on various run level, for run level 0 is shutdown, and run level 6 is restart and usually run level 1 i...


Complete Story


Sign up for PayPal and start accepting credit card payments instantly.
ILoveTux - howtos and news | About | Contact | TOS | Policy