Virtualize siduction with qemu-system-x86 64
This article will help you to get started with qemu-system-x86 version 1.7 in siduction as host and guest system.
qemu-kvm vs. qemu
The developement of a frontend for the kernelbased virtual machine (kvm) has begun as a fork of qemu with the name qemu-kvm or short "kvm". Since qemu version 1.4 all patches of the kvm fork have been integrated back into the qemu source. Also there has been much progress in the field of virtualization. There is a lot of outdated documentation around.
qemu as a backend
The application qemu concentrates on the bare execution of systems. It provides a very basic gui for interacting with machines, but hardly any management tools. For managing a farm of machines you will need other frontends like libvirt or openstack.
qemu as a frontend
In a graphical environment qemu will provide you with a graphical window which can display several views of your running machine. The standard view is the console of your machine which can be text or graphical. Additional views may be the qemu monitor or the output of a serial connection to your guest.
Prepare the host
Of course you need enough free RAM and harddisk capacity, but for a first glance we need only little resources. 2GB free RAM and 20 GB free diskspace is enough even for a siduction GNOME or KDE. Your host needs to run the kernel modul 'kvm' and luckily this is default in siduction. You can check if the modul is loaded:
lsmod | grep kvm
On intel systems the virtualization is often disabled in the BIOS, on AMD it tends to be active by default. To check if your processor is capable of supporting virtualization, search for the flag 'svm' (AMD-V) or 'vmx' (Intel-VT):
grep -E 'svm|vmx' /proc/cpuinfo
So you only need to install a few packages for qemu
apt-get update && apt-get install qemu-system-x86 qemu-utils
Start the first guest
Let's run some Live-media from your prefered Linux distribution! There is no preparation neccessary! All you need is a downloaded imgage in ISO format e.g. from University of Delaware .
Now start a Terminal and run your first virtual machine
qemu-system-x86_64 -enable-kvm -m 2048 -smp 2 -vga vmware -usbdevice tablet -soundhw ac97 -cdrom ~/siduction-13.2.rc1-december-kde-amd64-201312222013.iso
The machine will get a network connection of type network address translation (NAT) by qemu default.
|-enable-kvm||lets qemu use the kvm kernel modul to execute any code with almost native speed.|
|-smp||2||asign 2 cpu cores to your machine, will also create two threads on your host.|
|-vga||vmware||emulates a virtual vga card that utilises the xserver-xorg-video-vmware driver, which supports many different resolutions.|
|-usbdevice||tablet||allow absolute pointing device, no capturing of your mouse anymore|
|-soundhw||ac97||add an ac97 soundchip|
|-cdrom||~/siduction.iso||create an oldfashioned IDE-CDROM, will be replaced by the new option "-drive"|
Install to virtual HDD
We need to create an empty image for a virtual harddisk. qemu-img creates sparse files by default, so there is no waste of diskspace. The qcow2 format is qemus standard for disk images. It supports for snapshots.
qemu-img create -f qcow2 siduction.img 20G
The prepared image is added to our qemu commandline to enhance the capabilities of our machine.
In this example we choose the virtio interface which is supported by the linux kernel.
The resulting device name in the guest will be /dev/vda.
qemu-system-x86_64 \ -enable-kvm -m 2048 -smp 2 -vga vmware -usbdevice tablet -soundhw ac97 \ -drive file=siduction.img,index=0,media=disk,if=virtio,cache=unsafe \ -drive if=ide,index=2,media=cdrom,file=siduction-13.2.rc1-december-kde-amd64-201312222013.iso \ -boot order=cd,once=dc
Now the machine virtually has an empty harddisk! It will still boot from the virtual cdrom and you can do an installation to your new virtual disk.
The boot order will allow for direct rebooting into the installed siduction on the virtual disk.
To be continued
TODO: basic control via qemu monitor.
Some Linux distributions like Puppy, DamnSmallLinux or TinyCore are specializing in extrem minimal resource allocation. TinyCores ISO-Image is just 14 MB to download. This small system even boots fast enough in emulation mode without the -enable-kvm option. But with kvm you can boot up its graphical desktop in less than 4 seconds.
qemu-system-x86_64 -cdrom TinyCore-5.1.iso
qemu-system-x86_64 -enable-kvm -cdrom TinyCore-5.1.iso
Have fun with qemu-system-x86 and kvm!