KVM the Kernel based Virtual Machine is an open source virtualization infrastructure for the Linux Kernel. It requires a processor with hardware virtualization extension and has been ported to FreeBSD and Illumos at the form of loadable kernel modules. A large set of operating systems work with KVM with many versions of Linux, BSD, Solaris Windows, ReactOS, Plan 9 and AROS Research Operating. KVM is proven to be far faster and smoother at running virtual machines than any other virtualization platform.
In this article we will list the features of the KVM and how we can use it to create a virtual machine under RedHat based-distributions.
Using KVM, we can run multiple virtual machines running unmodified Linux or Windows images. Each virtual machine has private virtualized hardware: a network card, disk, graphics adapter, etc. It is developed by Red Hat Corporation to provide a virtualization solution and services on the Linux operating system platform. KVM is designed over the primary Linux OS kernel.
KVM continues to add innovative features that address virtualization demands. It has a large set of features where we can list the following ones:
- KVM is a type of hypervisor that enables, emulates and provides for the creation of virtual machines on operating systems
- KVM can be installed on all x86 processors and provide separate instruction set extensions for Intel and AMD processors.
- KVM supports multiple different guest operating system images including Linux Kernel, Windows, BSD and Solaris.
- It also allocates separate virtualized computing resources for each virtual machine such as the processor, storage, memory, etc.
- It has a Virtual CPU hot add capability.
KVM only works if your CPU has hardware virtualization support – either Intel VT-x or AMD-V. To determine whether your CPU includes these features, use the following command:
# grep -e 'vmx' /proc/cpuinfo
Use the following command to check that the KVM modules are loaded in the kernel:
# lsmod | grep kvm
Now you will need to have a root account or non-root user with the “sudo” privileges. So use the following command to up-date the system:
# yum update
And the following command to check that Selinux is at the permissive mode.
# setenforce 0
Installation of the KVM:
We will start this section by installing the “qemu-kvm” and “qemu-img” packages using the following command:
# yum install qemu-kvm qemu-img
Now we will install the “virt-manager”, “libvirt-client”, “virt-install”, “libvirt” tools to administrate our platform using the following command:
# yum install virt-manager libvirt libvirt-python libvirt-client
And also there are other required packages for the RHEL/CentOS must be installed like: “Virtualization-client”, Virtualization platform” and virtualization tools where we will use the following command to install them:
#yum groupinstall virtualization-client virtualization-platform virtualization-tools
Use the following command to restart the daemon “libvirtd”:
#systemctl restart libvirtd
Then use the following command to verify the state of the daemon:
#systemctl status libvirtd
Now we will start the creation of our virtual machine. We will use the “virt-manager” tool to manage our virtual platform:
Now from the “file” tab, select “add connection”, then check “connect to remote host” option then provide Hostname/IP of the remote server. Now you have to select the directory in which you will store your files and folders. So we will create the Volume Disk, you have to return to our localhost and select “details” and then “storage” tab. Then press “New Volume” button and chose a name and size for your new volume disk. The allocation size is the actual size for your disk which will be allocated immediately from your physical disk after finishing the steps.
You have to verify now the path of the new disk image by using the following command:
# ls -l /var/lib/libvirt/images
-rw-------. 1 root root 10737418240 Apr 14 18:51 virtimag.img
In the main window now hit the button “VM” select the installation method to create the virtual machine. And you have two options either to use the CDROM/DVD or the ISO image to specify which local will install media. In our article we will use the ISO image. The storage has return back, we will use the virtual disk which we have created early to install virtual machine on it.
If you like to change some configuration or doing some customization just check “Customize configuration before install” option. Then click finish and wait seconds, control console will appear for your Guest OS to manage it
In this article we gave you an introduction to the KVM, how to manage your virtual platform and how to deploy your virtual machine.