Wednesday, 29 April 2009

Easily Configure QEMU to Run Bootable ISO Images

QEMU is a powerful, open-source machine emulator which allows you to run virtually any operating system inside your currently running distribution. In this brief tutorial I'll show how to run distributions for which the ISO is available, directly from within Debian or Ubuntu.

Ubuntu Jaunty Jackalope running in QEMU

First, install the package qemu:

apt-get install qemu

Next, we will need to create a QEMU image, so use the following command (and adjust parameters if needed to):

qemu-img create -f qcow qemu_disk.img 3G

The qcow (QEMU Copy-on-Write) specifies the disk image type, while the 3G parameter specifies the amount of memory that can be used (3 GB in this case).

Given that we have an ISO distro image, in order to start it in QEMU use, for example:

qemu -cdrom distribution_image.iso -hda qemu_disk.img -m 256 -boot d

-cdrom distribution_image.iso chooses the ISO image which should be loaded
-m 256 switch sets the virtual RAM size to 256 MB, default being 128
-boot d specifies to boot on CD-ROM, default being c, hard-disk

Below is a screenshot showing Ubuntu 9.04 Jaunty Jackalope running in QEMU on Debian Lenny, after giving the command (one line):

qemu -cdrom ubuntu-9.04-desktop-i386.iso -hda qemu_disk.img -m 256 -boot d

Booting up Ubuntu 9.04 Jaunty Jackalope from the Desktop CD


Anonymous said...

I had troubles running Jaunty installer inside Qemu virtual machine.

The edit boxes just don't get keyboard focus on clicking on them.

Have you expirienced such troubles?

Laurent said...

Qemu is really a great tool to try Linux or BSD distributions, without having to reboot your PC.

But the most notable feature of Qemu is its ability to emulate other architectures. So, you can run a Linux PPC distribution from your x86 computer. This can be really interesting for embedded or cross-platform software development.

Anonymous said...

"Why to prefer this to for example "Virtualbox".. ?"

Ummm... because VirtualBox requires admin rights? This doesn't.

andy said...

When booting arch in qemu, It gets to this stage and stops:
trying to set up timer as virtual wire IRQ

Also, in the terminal, i get this message:
Could not open '/dev/kqemu' - QEMU acceleration layer not activated: No such file or directory

What is the problem????

Taimoor Mirza said...

Install QEMU accelarator. It will solve your problem.