Contents
QEMU creates a virtual machine, similar to VMWare, Virtualbox, KVM, and Xen. It allows you to run one operating system from within another operating system. The operating systems can be the same ones, or different. Your memory resources will be divided between your native (host) OS and your virtual machine (guest) OS. You will therefore notice a decrease in performance of activities in both the host OS and the guest OS.
Therefore, if you plan to use QEMU only to create a Windows virtual environment in order to run Windows programs, consider using one of several free Linux SoftwareEquivalents instead. If you need to run only a single Windows program, also consider using Wine instead of QEMU. Running a virtual machine environment such as QEMU will slow down your computer noticeably.
Also see WindowsXPUnderQemuHowTo, https://wiki.ubuntu.com/ScreencastTeam/HowToSetupQEMU .
Also consider trying a QEMU interface, such as Qemulator, or the package qemu-launcher.
Another QEMU GUI is virt-manager. It manages virtual machines not only for QEMU, but also for kvm and xen, in a consistent fashion (through libvirt).
What is QEMU ?
QEMU is a fast processor emulator. The package currently supports arm, powerpc, sparc and x86 emulation. By using dynamic translation it achieves reasonable speed, while being easy to port to new host CPUs. QEMU has two operating modes:
- User mode emulation: QEMU can launch individual Linux processes compiled for one CPU on another CPU.
- Full system emulation: QEMU can emulate a full system, including the processor and peripherals. This enables testing and debugging of system code in a contained (and quarantined) virtual system. It can even be used to host several virtual machines simultaneously on a single server (given enough host processor power and RAM).
As QEMU requires no host kernel patches to run, it is safe and easy to use.
Why use an emulator?
QEMU emulates everything, including the CPU, so it is slower than the host system. Hardware acceleration will not be as effective for a software OS emulator. Nevertheless, it is a pretty good way of testing a distribution, without having to repartition your drive or set up new hardware.
Preparation of the QEMU virtual environment
QEMU is available as a standard package in the Universe repository. (There are on how to install packages elsewhere in this guide. Unlike some other virtualization systems (like VMWare), separate kernel modules are not needed.
- Download the Ubuntu ISO file you wish to install into a virtual QEMU environment.
Recent QEMU versions support networking out of the box. There is a "linux-test" add-on at QEMU's site, a one-line script. Alternatively, run this command before starting the emulator: sudo /sbin/ip addr add 172.20.0.1/12 dev eth0
- A virtual disk is needed for the virtual machine. A virtual disk is made by creating a file of a size appropriately large to contain the full guest OS:
qemu-img create ubuntu-test 3G
The 'qemu-img command (included in the QEMU package) creates a 3Gb image named 'ubuntu-test'. (qemu-img also supports other compressed and VMWare compatible disk-image formats.) Another way of creating such images is using the standard dd of=ubuntu-test bs=1024 seek=4194304 count=0 This will create a 4GB file named
We are ready to install the guest OS. Download, for example, the latest development version of Ubuntu. Assuming your ISO image is named qemu -hda ubuntu-test -cdrom ubuntu-6.10-desktop-i386.iso -m 192 -boot d A word of caution: giving too much memory to the virtual system will make your native host machine start swapping to disk, which will slow things down a lot. On the other hand, giving it too little memory will make the virtual machine start swapping, which will slow things down as well. Clearly, the more RAM you have, the better. As the installer boots and goes through options, choose the defaults at each step. The installer should detect the virtual network properly and install without diificulties. qemu -hda ubuntu-test -cdrom ubuntu-6.10-desktop-i386.iso -m 192 Note that the boot parameter is removed this time, so that it will boot ubuntu from the new virtual hard drive, not from the "cd".
The reason to install QEMU in Windows is so that you can run an Ubuntu Server in a virtual machine. Such a virtual machine can be copied and moved. At this time, it is best to download the source and then compile QEMU in Windows using these instructions. Once QEMU is running in Windows, usage is the same as in Linux.
First of all, running an OS on emulated hardware is not screamingly, insanely fast. Don't expect to run anything demanding on this system, other than for testing purposes. That said, even on fairly underpowered hardware, it is certainly fast enough to test a distribution, perhaps install some packages, see how it all fits together. This is also a good tool for increased security system management. QEMU can have a read-only disk image with a separate write-back file, so one use would be to test the installation of an intrusive packages (or test your own packages to make sure they don't break the system) without actually touching your real system. If it turns out it breaks the system, just remove the write-back file and it never happened. If you have a very fast network connection, you may want to remove the -cdrom parameter for future invocations of QEMU and comment out the line starting with sudo nano /etc/apt/sources.list Installation of an operating system from ISO to the QEMU environment
Installing QEMU in Windows
Usage