QEMU quick start guide
QEMU
is a virtual machine program. So, that's a machine in the machine. There is a computer, called host,
which runs an OS, called host OS, and QEMU (besides other programs). Inside
QEMU, there runs an OS, called guest OS. QEMU is a simple program ("exe") from the host point of
view.
While
QEMU is able to handle different host and guest architectures like PPC, ARM or MIPS (not complete), this quick start guide only covers x86 where host and
guest architectures are the same. To emulate a guest x86 machine on a host x86
we use QEMUs Full System Emulation mode.
Windows guest on Linux host
1. Download QEMU Binary distribution for linux-i386 and install it. Installation is simply done by
extracting the contents of the tar archive in root directory ("/"). It will extract its contents to /usr/local/bin
and /usr/local/share.
2. 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:
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). A fresh WinXP
installation will use e.g. ~1.7Gb. For more information on creating a blank
image see Disk Images.
3. 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. Windows installation CD) into the real
CD drive of your host computer. Then run
Both will run the virtual machine. It will have
two drives, the primary master (/dev/hda) is the 3G image (-hda c.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 c.img as
"hardisk" (image).
So,
the virtual machine is started. It shows a window in the monitor like on a real
hardware. 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.
If
you don't like windowed mode, you can use special keys. Press ctrl-alt-f to go fullscreen.
When you'd like to use your host OS, press ctrl-alt to release mouse grab
or try seamless mouse. You can return to the VM any time.
When
you stop guest OS, and the virtual machine halts, QEMU exits. But the image
file (c.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 c.img) will have increased dramatically. You can now start the system you
just installed by booting from the "hardisk" (c.img):
If you want, you can compress c.img to backup,
or do anything. Note that closing the VM window while guest OS is running is
like unplugging the computer. It might complain next time
-localtime
-net nic -net user option is not necessary here because it is
enabled by default if no -net option is specified. This is, by default,
"user mode" (user-net) networking, which is the simplest way to reach internet from inside.
It just works (getting IP address from DHCP automatically)
5. To increase emulation speed, you would like to install QEMU Accelerator (KQEMU). Download latest QEMU Accelerator Module and follow KQEMU Compilation and kqemu installation.
6. 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 Linux quickly. There
are several areas for additional configuration (i.e. additional drives, further
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.
No comments:
Post a Comment