KVM ( Kernel-based Virtual Machine ) is free and open source virtualisation software. You can create multiple VM (virtual machines) , each VM has its own private virtualised hardware like disk, CPU, RAM etc. It was included in Linux kernel mainline in kernel version 2.6.20.
In case you are looking for some alternate of VirtualBox, we will strongly suggest KVM to use. We are also personally using this awesome virtualisation software.
For installing the KVM you must have following prerequisites.
1. Enable Virtualisation in your system BIOS.
2. Check your system CPU if it supports virtualisation. Run the given below command.
egrep -c '(vmx|svm)' /proc/cpuinfo
When you get the output from above command either 1 or more it means CPU supports the virtualisation else 0 or less means it does not support.
3. Check Ubuntu 16.04 LTS architecture by running one command i.e
x86_64 represents 64 bit kernel.
i386, i486, i586 or i686 represents 32 bit kernel.
The 32-bit OS are limited to 2GB RAM at maximum for a given Virtual Machine.
32-bit kernel will only host 32-bit guest kernel whereas 64-bit kernel can host both 32-bit and 64-bit guest O.S.
Follow steps to install KVM on Ubuntu
In this section we will write down the steps to install the KVM. In our previous post we have learned to install KVM on Ubuntu 14.04 LTS Desktop.
1. Install KVM and other dependencies packages
In Ubuntu 16.04 LTS, you can use the command
apt-get both.There will be no differences in packages installed via apt or apt-get command so you are good here.
sudo apt update sudo apt install qemu-kvm libvirt-bin bridge-utils
2. Know about new users and group for KVM software
Once you installed the packages, some addition will happen in number of users and group.
(a) Two users will be created.
sharad@linuxworld:~$ tail -2 /etc/passwd libvirt-qemu:x:64055:129:Libvirt Qemu,,,:/var/lib/libvirt:/bin/false libvirt-dnsmasq:x:121:130:Libvirt Dnsmasq,,,:/var/lib/libvirt/dnsmasq:/bin/false sharad@linuxworld:~$
(b) Two groups will be created.
sharad@linuxworld:~$ tail -2 /etc/group kvm:x:129: libvirtd:x:130:sharad sharad@linuxworld:~$
You may have noticed the used called ‘sharad’ is member of group ‘libvirtd’. It means this user can use the KVM.
3. Verify KVM installation
This is quite easy to verify the KVM installation. Run the command –
virsh -c qemu:///system list
First time, it will show the error.
sharad@linuxworld:~$ virsh -c qemu:///system list error: failed to connect to the hypervisor error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Permission denied sharad@linuxworld:~$
To solve this, you should logout and login back in your desktop. Means the currently login user should re-login in system.
Once you are login back, re-run the command. This time you should get the output as given below. It is blank because no VM is created.
sharad@linuxworld:~$ virsh -c qemu:///system list Id Name State ---------------------------------------------------- sharad@linuxworld:~$
4. Install Virtual Machine Manager
Here we are using Virtual Machine Manager which is a desktop application to manage the KVM virtual machines through libvirt.
Run this command to install Virtual Machine Manager.
sudo apt install virt-manager
You can open the Virtual Machine Manager by typing the same in Dash Home.Click the icon , it will open the application.
To open the Virtual Machine Manager through command line, type –
Earlier when we installed KVM in Ubuntu 14.04 LTS Desktop, we have faced problem while creating first VM where we solved it as well. In Ubuntu 16.04 LTS Desktop, we have not found as such any issue.
Thank you for posting this. It is useful.