Search This Blog

Thursday, July 14, 2016

KVM on Ubuntu Part I

How to Install KVM on Ubuntu 16.04?

I have been using Ubuntu a my primary Operating System for a long time now. Since my work involves working with new technologies all the time (mostly proprietary, like Microsoft Citrix Vmware AppSense etc..). I have to build virtual lab environments all the time. I could use Windows Server however that lasts me only for 180 days which is the standard evaluation period. I need to install and configure various products on top of Windows Server all the time. I tried all other options and over a period of time I have come to conclusion that there is nothing better than KVM for my purpose. It is free and Open Source and most importantly it performs really well.

Why use Ubuntu for KVM? As most of you out there who may have used KVM in the past would agree that KVM Is a very good virtualization platform, we all know that Red Hat is the main contributor to the code. Red Hat has moved away from the Xen Hypervisor to KVM. So Why not use something like a CentOS? Answer is simple KVM works equally well everywhere. I do all my Virtualization labs on my laptop which does not have too much RAM. Moreover I use Ubuntu on my laptop as a daily driver, so I decided to use KVM on Ubuntu. I chose Ubuntu because it is what I use day in and day out. It just works, I don't have to tweak it too much. You would be surprised to know that I actually like the default theme and colors! now you would say "YUCK", be my guest.

KVM itself is the whole setup which consists of QEMU the Hypervisor, Virt-Manager the console and libvirt, the subsystem which Virt-Manger uses to connect to QEMU. Libvirt can manage Xen and LXC as well. The goal of the post is not to get into the technical architecture/details, there is plenty of material online for that. I just want to provide a step by step walk through which will help you in getting up and running with KVM in no time.

After using it for some time now, I think it is time for me to share the secret sauce with you all and start a series of How to posts on my blog. Hence this blog post.

With that out of the way. Here are the steps to follow.

1. Install KVM by typing the following command in terminal.

 sudo apt install kvm virt-manager

Press y and then enter this downloads and installs the required packages. With Ubuntu all the dependencies are automatically selected and installed.

2. Reboot the system.

Technically there are other steps that are required like adding your user account to kvm and libvirt user groups. However Ubuntu automatically takes  care of that. All you need to do now is reboot and you should be fine.

3. Search for virt-manager in dash. Once rebooted hit the super/Window key to open dash. Type virt-manager and you should see something like this.

4. Launch Virt-Manager application. Below is how it looks like.

It lists the Hypervisors which it has connected to. This time around it shows QEMU/KVM. You could connect to multiple instances of KVM running on different servers using virt-manager application.

This way we have now installed KVM on Ubuntu and we are ready to configure basic settings so we could use it and spin up some Virtual Machines.
In my next how to, I will go through the Initial configuration and the best configuration that works for me and some general tips about getting the best out of this wonderful technology.