(Last Updated On: August 22, 2018)

Virtualization on both Ubuntu and Ubuntu Desktop made easier with Kernel-based Virtual Machine virtualization infrastructure for the Linux Kernel.
Virtualization is the hottest trending topic in system Administration nowadays. Virtualization is what allows you to create multiple instances of an operating system all running on same hardware. Each virtual machine is allocated hardware resources hence good hardware resource utilization.

We had talked about Virtualbox Installation on Linux. Today we’ll go through the installation of KVM. KVM is a free software whose support is directly built into Linux kernel. It is supported by all Linux distributions. KVM turns Linux Kernel into a hypervisor.

The requirement is the only processor that support virtualization.To confirm whether your Processor has virtualization extensions run the following command

egrep '(vmx|svm)' /proc/cpuinfo

If you get any output then you are good to proceed.

Install the required packages

sudo apt-get install qemu-kvm libvirt-bin

Additionally, you can install ubuntu-vm-builder.

sudo apt-get install ubuntu-vm-builder

Add your user account to libvirtd group. This user will have the privileges to fire up Virtual Appliances. Replace “username” with your actual username.

sudo adduser "username" libvirt

Test whether KVM is functioning and that your user account can manage it, virsh command is used for this purpose.

virsh -c qemu:///system list

if you want your Virtual machines to communicate with machines outside KVM host, you’ll have to set up bridged networking so that your  Virtual Machines will appear to be on the same network as your host.

In our example, we’ll bridge the Ethernet eth0 interface.

Bridging eth0 interface using DHCP

sudo vim /etc/network/ interfaces.

Look for the lines below,

auto eth0
iface eth0 inet dhcp

Change the inet mode for eth0 from dhcp to manual
So that it looks like one below.

auto eth0
iface eth0 inet manual

Now add the following just below it.

auto br0
iface br0 inet dhcp
bridge_ports eth0
bridge_fd 9
bridge_hello 2
bridge_maxage 12
bridge_stp off

See below image

Bridging eth0 interface with Static IP address configured.

Look for the following lines,

auto eth0
iface eth0 inet static

Change inet mode from static to manual . It will look something like this.

auto eth0
iface eth0 inet manual

Then add IP address information and bridging configurations just below it.

 auto br0
iface br0 inet static
bridge_ports eth0
bridge_fd 9
bridge_hello 2
bridge_maxage 12
bridge_stp off

See below imageThen restart Network daemon.

sudo /etc/init.d/networking restart

Confirm the newly created bridge interface with the command

sudo ifconfig -a

To manage your Virtual Machines with the Graphical interface, install virt-manager

sudo aptitude install virt-manager

To start virt manager just type the following command on terminal

sudo virt-manager

Virt Manager can then be run on a host machine. It’s not limited to local KVM management. You can install this package on another computer in your network then use ssh to connect to KVM Server.
Go to Menu–>File–>Remote tunnel over ssh.

Make sure Qemu is selected hypervisor and then type hostname for KVM server and the click connect.