How-To Qemu: Run a Windows inside Linux

1 minute read

QEMU is a generic and open source processor emulator which achieves a good emulation speed by using dynamic translation.


apt-get install qemu  sharutils

To make qemu run faster, you can download source to compile kqemu , a kernel module for qemu. If you want to use it, you will need to download, compile and install it.

First grab kqemu sources, uncompress it and build it. note that you will need kernel headers in order to be able to compile it.

tar -xzvf kqemu-1.3.0pre9.tar.gz
cd kqemu-1.3.0pre9
sudo make install

Ok, by now, you should have /dev/kqemu created and kqemu.ko in /lib/modules/uname -r/misc .

Now, we are going to install windows from our linux. To do so, you first need to create a blank disc image, which is going to be our windows hardrive:

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

This create a blank disc image which will at the maximum reach 3G space. Note that the space is not taken in on shot, it will grow as you add content to the image.

Now, we are going to install windows. I you have windows on a CD, then run:

qemu -cdrom /dev/cdrom -hda windowsxp.img -m 256 -boot d

If you have a windows cd image on you hard-drive, then run:

qemu -cdrom my_os_install.iso -hda c.img -m 256 -boot d

This will run the virtual machine where 2 drives are being seen: the primary master /dev/hda which is in fact you blank disc image (windowsxp.img) and a secondary master which is your cdrom or cdrom iso. We allocate 256M of RAM (-m 256) and boot on the cdrom (-d).

If the installation went fine, you can now start your windows system by typing:

qemu -hda windowsxp.img -m 256

which will boot the virtual machine on your newly created windows image: windowsxp.img.

To run your virtual machine in full screen, you can use the key binding Ctrl+Alt+f.