There are a handful of desktop virtualization products which work on Linux such as VMware, Virtual Box UML and so on. However KVM is a upcoming star in this busy market place. KVM (kernel virtual machine) is a upstream supported virtualization product. Redhat and Canonical are both betting hard on this technology with it becoming standard in RHEL6 and its already the power house behind Ubuntu Enterprise Cloud. If your looking to use desktop virtualization rather than server virtualization its very easy. In this simple tutorial I’ll show you how to get up and running with a NAT’d connection that will provide your guest access to the internet via the use of a local (on your PC) network. Later on this blog I’ll cover more advanced topics such as a bridged networks, which will allow the virtual machine to appear as if its a real machine on the network.
Prerequisite’s:
First lets see if your machine can use KVM technology by checking if your processor supports the hardware acceleration required, from a terminal run these commands:
egrep -c ‘(vmx|svm)’ /proc/cpuinfo
This will return a numeric value. Anything above 0 is good. If you see a zero then I’d recommend using something like Virtualbox which will run a little slower as your processor doesn’t support virtualization. Newer processors should be fine and they provide an abstraction layer that allows the guest virtual machine to interact directly with the hardware, thus you get a speed boost!
NOTE: You may need to go into BIOS and enable virtualization (This is vendor specific and will boost the speed of all the virtualization on your machine).
If you want to give more than 2GB of RAM to your VM’s you need to be on a 64bit computer. You can check this from the terminal by running:
egrep -c ‘lm’ /proc/cpuinfo
0 means your on a 32bit machine 1 means 64bit and your good to go.
Installation:
Now you’re ready to install. From the terminal run:
sudo apt-get install qemu-kvm libvirtd-bin virt-viewer
Thats It you should be done. If you want to check that the KVM module is loaded from the terminal run:
lsmod | grep kvm
If you don’t get any output simply run:
sudo modprobe kvm
You also need to to make sure libvirtd is enabled and running.
sudo gedeit /etc/default/libvirt-bin
Make sure you have this line (you may have to edit it) start_libvirtd=”yes”
Now start libvirtd
sudo service libvirt-bin start
Now back to the gui go to Applications -> System Tools and click Virtual Machine Manager, your almost ready to create your first machine. Now just click File -> Add Connection and accept the defaults from the pop up window like the image below:
Now if you click the icon in the top left hand corner of virt-viewer you will be greeted with a wizard to build your first virtual machine. I selected install from ISO for this but you could equally use any of the other options, if you have the correct things in place to do so.
Now point the Use ISO image box to the location of the ISO you wish to use. I also set the OS type and Version although this isn’t necessary.
Now you have the option to set the RAM you wish to dedicate to the machine and number of virtual CPU’s. The max number of VCPU’s is dictated by the output from the egrep -c ‘(vmx|svm)’ /proc/cpuinfo command you ran before, which shows you how many of your core’s support the virtualization extensions.
The next stage asks you to set the size of the virtual hard disk for your new machine, I went for the standard 8GB as this is just a test server instance.
The next screen provides a summery of your options and allows you to pick virtual networking adaptor. As we haven’t set up any bridging yet leave this as the default.
Once you click finish your machine should start running. If you click on the VNC window that’s now popped up and your Keyboard and Mouse become locked to that screen press CTRL+ALT and you’ll return to your desktop.










