How to install KVM - Virtualization extension in Ubuntu

To install KVM in Ubuntu 16.04

KVM is a virtualization extension for the Linux Kernel. It requires a processor with hardware virtualization support and can be tied up with any operating systems. Installation of KVM is explained in this manual.


To install KVM

Run the following command to install the dependency.

root@linuxhelp:/home/user1# apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
Reading package lists... Done
Building dependency tree       
Reading state information... Done
...
...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu4) ...
Processing triggers for initramfs-tools (0.122ubuntu8) ...
update-initramfs: Generating /boot/initrd.img-4.4.0-31-generic

Append the user to the libvirtd group.

root@linuxhelp:/home/user1# adduser `id -un` libvirtd
Adding user `root'  to group `libvirtd'  ...
Adding user root to group libvirtd
Done.

Utilise the following command to install KVM.

root@linuxhelp:/home/user1# apt-get install virt-manager
Reading package lists... Done
Building dependency tree       
Reading state information... Done
....
....
Setting up virt-manager (1:1.3.2-3ubuntu1.16.04.1) ...
Setting up virt-viewer (1.0-1) ...
update-alternatives: using /usr/bin/spice-xpi-client-remote-viewer to provide /usr/bin/spice-xpi-client (spice-xpi-client) in auto mode
Processing triggers for libc-bin (2.23-0ubuntu3) ...


To launch KVM

Run the following command to launch KVM.

root@linuxhelp:/home/user1# virt-manager



To Create a new VM

Select the installation type and click Forward.

Select the location of your media and click forward.

Choose your Memory and CPU settings

Select a location for the Storage of the VM

Enter the name for your VM and select a network. Then finally click Finish.

Now Power on the VM.

FAQ
Q
Is KVM is stable?
A
KVM is stable and used in production. As with most open source projects, development snapshots are less stable than the stable release series.
If your name is Andreas Mohr, you're reporting bugs in the wrong place.
Q
How can I use KVM with a non-privileged user?
A
*The cleanest way is probably to create a group, say kvm, and add the user(s) to that group. Then you will need change /dev/kvm to owned by group kvm.

*On a system that runs udev, you will probably need to add the following line somewhere in your udev configuration so it will automatically give the right group to the newly created device (i-e for ubuntu add a line to /etc/udev/rules.d/40-permissions.rules).

KERNEL=="kvm", GROUP="kvm"
Q
What is virtualization?
A
Virtualization is a broad computing term used for running software oncurrently and in isolation from other programs on a single machine
Q
What do I need to use KVM?
A
We will need an x86 machine running a recent Linux kernel on an Intel processor with VT (virtualization technology) extensions, or an AMD processor with SVM extensions (also called AMD-V). Xen has a complete list of compatible processors. For Intel processors, see also the Intel® Virtualization Technology List.
Q
What is Intel VT / AMD-V / hvm?
A
*Intel VT and AMD's AMD-V are instruction set extensions that provide hardware assistance to virtual machine monitors. They enable running fully isolated virtual machines at native hardware speeds, for some workloads.

*HVM (for Hardware Virtual Machine) is a vendor-neutral term often used to designate the x86 instruction set extensions.