Virtualization on Ubuntu Server and Ubuntu Desktop 14.04 with KVM

With kernel-based virtual machine virtualization infrastructure for the Linux kernel, virtualization on Ubuntu and Ubuntu desktops becomes easier.
Virtualization is the hottest trending topic in systems management today. With virtualization, you can create multiple instances of an operating system, all running on the same hardware. Each virtual machine is allocated hardware resources, so it can make good use of hardware resources.

We have already discussed Virtualbox installation on Linux. Today, we will complete the installation of KVM. KVM is free software with support built directly into the Linux kernel. All Linux distributions support it. KVM turns the Linux kernel into a hypervisor.

This requirement is the only processor that supports virtualization. To confirm if your processor has a virtualization extension, run the following command

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

If you get any output, you can proceed.

Install required packages

sudo apt-get install qemu-kvm libvirt-bin

In addition, you can install ubuntu-vm-builder.

sudo apt-get install ubuntu-vm-builder

Add your user account to the libvirtd group. This user will have privileges to start the virtual device. Replace “username” with your actual username.

sudo adduser "username" libvirt

To test if KVM is working properly and if your user account can manage it, you can use the virsh command.

virsh -c qemu:///system list

If you want the virtual machine to communicate with a computer outside the KVM host, you must set up a bridge network so that the virtual machine appears to be on the same network as the host.

In our example, we will bridge the Ethernet eth0 interface.

Bridge eth0 interface using DHCP

sudo vim /etc/network/ interfaces.

Find the line below,

auto eth0
iface eth0 inet dhcp

Change eth0’s inet mode from dhcp to manual
This will look like the one below.

auto eth0
iface eth0 inet manual

Now add the following below it.

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

See belowVirtualization on Ubuntu Server and Ubuntu Desktop 14.04 with KVM

Use the configured static IP address to bridge the eth0 interface.

Look for the following lines,

auto eth0
iface eth0 inet static

Change the inet mode from static to manual. It looks like this.

auto eth0
iface eth0 inet manual

Then add IP address information and bridging configuration below it.

 auto br0
iface br0 inet static
address 192.168.100.19
network 192.168.100.0
netmask 255.255.255.0
broadcast 192.168.100.255
gateway 192.168.100.1
bridge_ports eth0
bridge_fd 9
bridge_hello 2
bridge_maxage 12
bridge_stp off

See belowVirtualization on Ubuntu Server and Ubuntu Desktop 14.04 with KVMThen restart the network daemon.

sudo /etc/init.d/networking restart

Virtualization on Ubuntu Server and Ubuntu Desktop 14.04 with KVM

Confirm the newly created bridge interface with

sudo ifconfig -a

To manage your virtual machines using a graphical interface, install virt-manager

sudo aptitude install virt-manager

To start virt manager, simply type the following command on the terminal

sudo virt-manager

You can then run Virt Manager on the host. It is not limited to local KVM management. You can install this package on another computer in your network and then connect to the KVM server using ssh.
Go to Menu-> File-> Remote Tunnel on ssh.

Virtualization on Ubuntu Server and Ubuntu Desktop 14.04 with KVM

Make sure the Qemu hypervisor is selected, then type the host name for the KVM server, and click Connect.

Sidebar