KVM ( Kernel-based Virtual Machine ) is virtualisation software which is used for creating virtual machines on host system. In this post, we will share installation method of KVM on Ubuntu 14.04 LTS. We also include brief introduction of problem we have faced during installation and its solution we will also share.
We recommend you to read the official page of KVM.
Prerequisite
Because it is virtualisation software, it is very important to check below given requirement before installing the KVM on system.
1. Check processor supports virtualisation
Use the below given command, to make sure processor (CPU) supports virtualisation.
egrep -c '(vmx|svm)' /proc/cpuinfo
=> If output is 0 it means that your CPU doesn’t support hardware virtualization.
=> If output is 1 or more it support hardware virtualisation ( NOTE: virtualisation should be enabled in the system BIOS)
2. Check Operating System architecture
Use the any of the below given command to check Operating System’s architecture
arch
OR
uname -m
x86_64 represents 64 bit kernel.
i386, i486, i586 or i686 represents 32 bit kernel.
On 32-bit kernel install, we will be limited to 2GB RAM at maximum for a given VM.
32-bit kernel only host 32-bit guest kernel.Whereas 64-bit kernel can host both 32-bit and 64-bit guest O.S.
Follow installation steps of KVM on Ubuntu 14.04 LTS (Desktop)
Step 1 : Install KVM and other supportive packages
sudo apt-get install qemu-kvm libvirt-bin bridge-utils
Step 2 : Check the changes (For learning purpose)
Read the changes happened in /etc/group and /etc/passwd file.
Two group get created –
1. kvm
2. libvirtd (You can see user called sharad is part of this group. I login with this user and doing installation, hence by defualt it is part of this group)
sudo cat /etc/group
..
kvm:x:128:
libvirtd:x:129:sharad
Two new users get created. Both users have false login means it is required for KVM software.
1. libvirt-qemu
2. libvirt-dnsmasq
sudo cat /etc/passwd
..
libvirt-qemu:x:119:128:Libvirt Qemu,,,:/var/lib/libvirt:/bin/false
libvirt-dnsmasq:x:120:129:Libvirt Dnsmasq,,,:/var/lib/libvirt/dnsmasq:/bin/false
Step 3 : Verify KVM Installation
After installation of packages which we have done in Step 1. Run the below given command to verify KVM installation
virsh -c qemu:///system list
On first time we faced the error. Given below is details.
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:~$
Solution: For solving this, just relogin (logout – login back) with same user account into system.
Now run the same command once again. It should show below given output. It verifies, KVM installation is complete.
Step 4: Install Virt-Manager
To control and manage the KVM in our desktop, we will install virt-manager.
sudo apt-get install virt-manager
After installation get completed. To open the virt-manager simply run the below given command
virt-manager
On first time, we got the below given error while opening virt-manager
Solution is simple. Install the qemu system.
Close the opened Virt-Manager windows. And run the command –
sudo apt-get install qemu-system
Retry once again and open the virt-manager by using command
virt-manager
It should be opened without any problem.
Step 5 : Create first virtual machine
Before creating first virtual machine. stop/start libvirt-bin.
sudo stop libvirt-bin
sudo start libvirt-bin
Now you can create the Virtual machine , by opening virt-manager.
stop/start of libvirt-bin is solution of given below error
Unable to complete install:'unsupported configuration hda-duplex not supported in this Qemu binary'
At the time of creating our first VM, we got this error windows. Here is the reference
Good explanation .. Thanks a lot 🙂
This worked like a charm! Thanks SO MUCH for posting this!!
Thank you John,
Through this comment, I also want to convey that the post still works and yesterday I used same method to install KVM in Ubuntu 16.04 LTS (Headless).
Regards
Sharad
Hi, I’m trying to install KVM on ubuntu-14.04 server, when I press the command virt-manager its nothing happening. Can u suggest me?
Install virt-manager package.
Regards
Sharad
Thanks Sharad,
The install was a breeze.
Welcome Saad,
Really nice to see your helpful feedback.
Best Regards
Sharad
It works perfectly, step by step… 🙂
Thanks.
You are most welcome Juan. Delighted to see the tutorial is working for many readers.
Regards
Sharad
This is so awesome and staright forward. Its so cool to see somone that makes things easy and simple to understand and do
Thank You Nezspencer,
Love this feedback.
Regards
Sharad
Wht do you mean by For solving this, just relogin (logout – login back) with same user account into system.
? To reboot my PC ? I’m sorry if my question is silly,. I’m using ubuntu x86.
Hello Cristina,
That is correct :
just relogin (logout – login back) with same user account into system.
Regards
Sharad
Thanks, glad I found this as well. Very helpful and I believe I learned something too.
Your most welcome Jason, happy to see the post is helpful for many readers.
Regards
Sharad
Worked like a charm for Windows 7 installation on 14.10 (I have to learn some Windows stuff for work). Your instruction is very clear and straightforward. I’m clad I found it after a couple of more confusing ones. Thank you very much!
That’s appreciation build my confidence more, to write some more useful posts for all.
Thankyou very much.
Regards
Sharad
Thanks! This was really helpful for setting up acceleration with Android Suite emulation 🙂
Welcome Patcon.
Regards
Sharad
Very good and educational description