When thinking about virtualization,everybody immediately thinks about VMWare. And it must be said,the product they offer is very decent but also comes with a “decent” price. As an alternative,it’s worth looking into KVM for your virtualization. As with the VMWare product range,KVM offers full virtualization and it can compete with VMWare regarding stability and performance.
Virtualization-terminology
To prevent things getting confused I would first like to clear out some terminology used for virtualization. For somebody working on a daily basis in virtual environments,these might be clear but can be rather confusing for others.
Host: the machine that hosts other system,KVM will be installed on this machine
Guest: the system running on the host,also referred to as VM,Virtual Machine or domain.
Hypervisor: the piece of software that enables virtualization on the host. For example: KVM,ESXi,Xen,…
Part1: KVM installation and preparation
KVM hypervisor and VM-extensions
As mentioned earlier,KVM offers,as VMWare,full virtualization. This means that a full system,which looks like a real physical system to the guest-OS,will be offered. Besides full virtualization,there is also such a thing as paravirtualization,as Xen can offer. Paravirtualization givesyou higher performance but needs a modified guest-OS and is basically limited to *nix-systems. Full virtualization enables you to run unmodified guest-systems and thus also most proprietary systems as Windows. In order to be able to use full virtualization,you either need some virtualization-extensions on your cpu or use emulation.
First thing to do is to check if the host-machinesupports VM-extensions. On the x86 platofrom,those are either AMD-V or Intel’s VT-X. In order to check if the installed cpu’s support those extensions,we need to check if the vmx (for VT-X) or svm (for AMD-V) flag exists in the cpuinfo-output:
When the output is 0,meaning that neither vmx or svm is found in the flags,it probably means that yourcpu doesn’t support those extensions and there is little you can do. When the extensions are listed,be sure to check if they are enabled in the systems BIOS since that would cause problems later on. In case your cpu doesn’t support VM-extensions,you are limited to QEMU-emulation in combination with KVM,which delivers a much worse performance in comparison. For this tutorial,I’ll assume that the VM-extensions are supported and enabled in the BIOS of the host-system.
KVM installation
The first step in the KVM installation is installing the necessary packages. Package virt-manager,xauth and dejavu-lgc-sans-fonts are also needed if you want to manage KVM with the graphical interface in combination withX11 forwarding. (for more information,checkthis previous post about X11 forwarding)
To install the required packages
Networking
For the networking part,our KVM-host will act as a router for its guests and wewill need to create a bridge interface to allow the guest to communicate out of the host. Guests will use NAT on the host to connect to the real network. To allow such type of setup it’s neededto allow ip forwarding in the kernel parameters.