QEMU on Microsoft Windows(c)

QEMU is an emulator for various CPUs. It works on Linux, Windows, FreeBSD, OpenBSD and Mac OS X (not complete). This guide covers installation of QEMU on a Windows host. To emulate a guest x86 machine on a host x86 architecture we use QEMU's Full System Emulation mode.

  1. QEMU on Microsoft Windows(c)
    1. QEMU installation
    2. Explore QEMU
      1. Starting QEMU
        1. Starting QEMU from the command prompt
        2. Using a batch file
        3. Using a shortcut
      2. Test-Benchmark
      3. x86_64 Emulation
    3. Guest OS installation
      1. Hard disk image
      2. Installation
      3. Usage
      4. Acceleration with KQemu
      5. Final shortcut
      6. Floppy and CD-ROM
      7. Real Harddisk Access
      8. Further configuration
    4. Uninstall
    5. Notes
    6. License
    7. Links
{i} Note that the Windows version is at alpha stage.

QEMU installation

I believe this installation page is bad please check. Download the latest QEMU for Windows version. Extract the zipped file, e.g to "C:\bin\qemu". When extracted, you are ready to use QEMU; no other installation is required.

{i} Thanks to Kazu for the now "old" QEMU for Windows page.

Explore QEMU

QEMU for Windows includes one test/demo Linux (linux.img) image which can be used to

First, we will use this test/demo image to explore your just-installed QEMU and to explain some basic concepts. After this, we will go on and show how to install your own guest OS on QEMU for Windows.

Starting QEMU

There are three ways to start QEMU.

Starting QEMU from the command prompt

To start QEMU with the demonstration image, type the following from within the directory containing qemu.exe

C:\bin\qemu> qemu -L . -hda linux.img

The -L . option tells QEMU to load the bios from the local directory. The -hda linux.img tells QEMU to boot from the hard disk image file named linux.img.

Using a batch file

The file qemu-win.bat starts QEMU. Double click boots Linux on your desktop. When you use command prompt (MS-DOS prompt), use

qemu.exe -L . -hda linux.img
-hda

set hard disk image

-L

set bios location

{i} If you call QEMU without any parameters, it will show its possible parameter list.

When your Windows mouse cursor disappears, use special keys Ctrl+Alt together or try seamless mouse. Please use Alt and Tab on Windows Me. Press Ctrl-Alt-f to toggle between fullscreen and window mode.

To exit from Linux, press Ctrl+Alt+2 keys together. With this you will switch to QEMU Monitor see QEMU prompt (qemu). Then type quit:

(qemu) quit

Typing help at QEMU prompt will show you all available commands:

(qemu) help

To switch back to Linux demo, use Ctrl+Alt+1.

Using a shortcut

Create a new shortcut of qemu.exe. Right click on the shortcut, append appropriate options like

"C:\Program Files\qemu-0.8.2-windows\qemu.exe" -L . -hda linux.img

at link to text field. Double click the shortcut.

{i} Path above is only an example. Adapt path used above to path and QEMU version valid for your installation

Test-Benchmark

There is a benchmark in shipped Linux image (linux.img). When Linux booted, type

sh-2.05b# cd nbench
sh-2.05b# ./nbench

INTEGER INDEX and FLOATING-POINT INDEX are index to Pentium 90MHz.

x86_64 Emulation

A file qemu-x86_64.bat also boots Linux on your desktop. It boots 32 bit and 64 bit OS.

Guest OS installation

Okay, now you should have a basic idea how to install and use QEMU for Windows. But goal should be to use self installed guest OS, not shipped demo/test image. Next steps will explain how to install own guest OS using Windows version of QEMU.

{i} You can use additional tools QEMU Manager and/or QEMUMenu for an easy installation and utilization.

Hard disk image

First you need a blank disk image ("harddisk"). This is like adding a blank disk to the virtual computer that QEMU creates. Use qemu-img to create a 3Gb blank disk image:

qemu-img.exe create -f qcow hda.img 3G

The last argument is the size of the image (3G). This 3G will be the maximum end size of the image file. It will grow while adding contents (writing files to the harddisk). For more information on creating a blank image, see Disk Images.

Installation

When you install an OS on a real computer you normally boot an installation CD/DVD or an existing image. We'll do the same with the virtual computer. Here you have two options: Either you use a real installation CD/DVD or you have an install ISO image. Depending on this, the next steps are slightly different.

* If you have an installation CD, put the CD (e.g. Linux installation CD) into the real CD drive of your host computer. Then run

qemu.exe -L . -cdrom "D:" -hda hda.img -m 256 -boot d

{i} This assumes that your Windows CDROM is D:. Change it according to your local configuration.

{i} See FAQ for special CD-ROM option format.

* Suppose you have an install ISO image, called my_os_install.iso. Then run

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

Both will run the virtual machine. It will have two drives, the primary master (/dev/hda) is the 3G image (-hda hda.img). The secondary master is that cdrom or cdrom image. Note that (from the host point of view) those are still two plain files (in case of iso image). But from the guest OS (running in the VM), those are real drives. Boot is done from secondary master (-boot d) using 256MB of RAM (-m 256) using hda.img as "hardisk" (image).

Now you can install the client OS just as you would in a real computer. First you probably need to create partitions, format them, run installer to copy files, and so on. If it needs to reboot the guest, feel free to do that, Qemu will not stop working. When you stop guest OS, and the virtual machine halts, QEMU exits.

Usage

If installation has finished, you can use installed guest OS. By installation, the image file (hda.img) is modified (the guest OS remains on that), so, you don't have to reinstall it every time. So, if you have installed the client OS shutdown it as you will do with your real computer. You will then note that the image file (here hda.img) will have increased dramatically. You can now start the system you just installed by booting from the "hardisk" (hda.img):

qemu -L . -hda hda.img -m 256

If you want, you can compress hda.img to backup, or do anything. Note that closing the VM window while guest OS is running is like unplugging the computer.

Acceleration with KQemu

To increase emulation speed, you may like to install QEMU Accelerator (KQEMU). Download latest QEMU Accelerator Module.

{i} You will need a Windows tool to extract tar archives.

{i} For Windows you only need kqemu.inf and kqemu.sys from this archive.

FollowKQEMU installation for Windows how to install and start kqemu.If you start QEMU now, it will probably run significantly faster. Try -kernel-kqemu option as well.

{i} If you want to use Windows XP as Guest OS, note that you must not use the -kernel-kqemu option during Windows installation (Accelerator Module is allowed). If you want -kernel-kqemu to work stable, you need to install Windows without ACPI support (just always use -no-acpi in QEMU options) or disable it in your guest Windows and then always use -no-acpi in QEMU. (as of versions 0.8.2&1.3.0pre9)

To check if everything is okay, use QEMU Monitor command info kqemu:

(qemu) info kqemu
kqemu support: enabled for user and kernel mode

Final shortcut

Assuming you installed your guest OS in hda.img and KQEMU like described above, you may now want to create a start shortcut (like described in Using a shortcut above) on your Windows desktop. For this create a shortcut to QEMU and append appropriate options like

"C:\Program Files\qemu-0.8.2-windows\qemu.exe" -L . -hda hda.img -m 256 -kernel-kqemu

Floppy and CD-ROM

You can add a floppy and a CD-ROM image and change it from QEMU Monitor. Like described above, QEMU Monitor can be seen by pressing Ctrl-Alt-2 key together. Pressing Ctrl-Alt-1 key together returns to your guest OS. It needs to convert floppy and CD-ROM to image file to use it. For floppy, there are many converters. Please choose your favorite one. If you have CD-R writing software, you can use it. If you don't have it, you can use mkisofs command in cdrtools.

When you want to change floppy or CD-ROM image, use

(qemu) change fda filename.img

or

(qemu) change cdrom fdimage.iso

at QEMU Monitor.

To use them together, type:

qemu.exe -L . -fda floppy.img -hda hda.img -cdrom cdimage.iso -m 256 -boot a -kernel-kqemu

starting QEMU from command line. Options are

-L

bios location

-fda

floppy image (a)

-hda

hard disk image (c)

-cdrom

CD-ROM image (d)

-m

memory size (Mbyte)

-boot

boot device floppy(a), hard disk(c), CD-ROM(d)

-kernel-kqemu

use KQEMU acceleration for user and kernel mode

Real Harddisk Access

First of all, use Windows's "partedit" and do a "list disk" to figure out the number of the disk we want to let QEMU access directly.

Then, do it like "-hda \\.\PhysicalDriveN" where N is the number of the disk for QEMU to access.

Further configuration

This guide tries to give you some basic ideas how to start with QEMU and to explain some first steps to get you up with QEMU on Windows quickly. There are several areas for additional configuration (i.e. sound, network, data exchange between host and guest, overlay images, VNC etc.) which are not covered here. For this, go on reading resources given in Documentation.

Uninstall

Notes

{i} Don't start two QEMU on one hard disk image. It will break the hard disk image.

{i} Double hyphen "--" is no longer needed. Please use a single hyphen for all options.

License

Please refer to files in License subfolder of your QEMU Windows installation. This program is provided "as is" and without any warranty. Please use it at your own risk.

Links


QemuOnWindows (last edited 2009-05-27 11:52:54 by xdsl-7303)