|
QEMU Howto
You can achieve virtualization in lots of ways. A useful technique is called emulation. Emulation, as the name implies, virtualizes the guest platform by simulating the complete hardware environment. Emulation is implemented in a variety of ways, even within the same solution. Examples of virtualization through emulation include QEMU and Bochs.
Installing QEMU (I am using debian etch for this howto, can easily be followed for any other linux distro)
|
sudo aptitude install qemu
|
You can speed things up to near native performance using the QEMU accelerator (KQEMU).
|
sudo aptitude install kqemu-common
|
|
sudo aptitude install kqemu-modules-2.6.18-5-686
|
(change the version if kernel is different )
Loading the kqemu module
Using QEMU
Now have a look at using QEMU to virtualize another machine with a typical desktop GNU/Linux environment. Emulating another machine is similar to how you treat a brand new computer. The first step is to install your operating system. Your new computer first has to have a place to install the operating system, so you need a hard disk.
QEMU provides a special command to create a hard disk called qemu-img. This utility can create images with various formats, but the best (for qemu) is called qcow (or qemu copy-on-write).The advantage of this format is that the size of the disk image is not the same as the physical file representing the image. In other words, the format allows holes that lead to a more compact disk image. For example, an empty 4GB disk image requires only 16KB.
For qemu-img, you provide an operation (create to create a new disk image), a format (qcow for the qemu image format), a size, and a name for the disk image. This example emulates a machine for a tiny Linux distribution intended for use in Flash. So, you create your disk image of 128MB as:
|
qemu-img create -f qcow /pathTo/disk.img 128M
|
You can get cflinux from here
|
wget ftp://ftp.cflinux.hu/pub/cflinux/iso/cflinux-1.0.iso
|
Note that if you plan to install a general purpose operating system such as Windows, Linux, or FreeBSD, a much larger disk size is needed. The result of this operation is a file called disk.img that appears as a 128MB disk when emulated.
You can get ready to use images of all free linux distros from
|
http://www.oszoo.org/wiki/index.php/Category:OS_images
|
Now you have an emulated disk (disk.img) and a CD-ROM from which you can install your operating system. The next step is to install the operating system on your hard disk. This is done simply with qemu:
|
qemu -hda /PathTO/disk.img -cdrom /PathToiso/cflinux-1.0.iso -boot d
|
Follow the installation instructions, per the CD-ROM install, to complete the installation of the ISO on the emulated hard disk. The install requests that you reboot. At this point, you can end the emulation (Ctrl-C in the qemu window). You can now boot your newly-installed operating system with the following command:
|
qemu -hda /PathTo/disk.img
|
Going Further
Windows guest on Linux host
|