ariya.io About Collections Archives

QEMU on Ubuntu to run Windows

3 min read

QEMU is a very nice virtual machine and system emulator. Running QEMU on a typical Ubuntu installation proves to be quite straightforward. Here is a quick step-by-step tutorial.

Obviously the easiest way to install it is via the binary package:

sudo apt-get install qemu

However, sometimes you want to play with the emulation, e.g. adding some extra logging here and there to understand how the guest system behaves. For this purposes, QEMU is a good choice. VirtualBox is another open-source virtualization solution, however it’s quite large compared to QEMU. Tweaking QEMU is a lot easier, the code base is small and humanly manageable.

To compile QEMU from source, we need to have all the necessary tools and libraries available. If your system is not set for compiling anything, then get it ready:

sudo apt-get install build-essentials libsdl1.2-dev

After that, let’s grab the source and build it:

git clone git://git.qemu.org/qemu.git
cd qemu
git checkout origin/stable-1.1
./configure --target-list=i386-softmmu --enable-sdl --disable-xen --disable-kvm
make
sudo make install

Note that the above is the minimalistic build, it can be used to launch typical operating systems though it is not optimized for maximum speed. If you want a better performance, I highly recommend enabling Xen and kvm, refer to the documentation for more detailed info.

Once it’s installed, let’s verify the setup by running a simple Linux system. For this purpose, use the small 20 MB Linux image readily available from QEMU testing page. Launch it like the following command and if nothing goes wrong, you’ll see a window with the terminal indicating a successful Linux boot.

qemu-system-i386 linux-0.2.img

What about running a much more mainstream OS like Windows? From my experience, installing Windows in a QEMU virtual machine is terribly slow. The technique that I finally used is to have it installed first on a faster virtualizer like VMware or VirtualBox. The latter works quite well. Simply download it from virtualbox.org and install it. After that, create a new virtual machine and then install Windows (32-bit version) there. Once it is done, we just need to convert the image so that QEMU can consume it, as easy as:

qemu-img convert Windows.vdi -O qcow2 Windows.qcow

Now launch the converted image:

qemu-system-i386 -m 1024 Windows.qcow

The specified option is to give the virtual machine 1 GB RAM. This is often needed since Windows is quite hungry for memory space. Now you should have Windows up and running. Even networking should work out of box and thus you can use it to run Internet Explorer (for web site testing etc). Granted, the performance is not the best but it works.

Related posts:

♡ this article? Explore more, check the archives, or follow me Twitter.

Share this on Twitter Facebook Google+

comments powered by Disqus