How to Configure KVM Hypervisor on Ubuntu Server?

Konstantin Olmezov
March 6, 2018
Konstantin Olmezov
Categories: Knowledge Base

TrueConf Server can be run on a virtual machine. However, it is complex and inadvisable to implement for inexperienced users, as enabling a virtual machine to operate correctly can be quite difficult at times.

This manual will teach you how to configure  KVM hypervisor on Ubuntu Server, more specifically on Ubuntu 14.04.03 Server x86-64.

This article is for informational purposes only and does not necessarily guarantee full server operation after taking all the steps.
TrueConf Technical Support does not advise users on configuring virtual machines and running TrueConf Server on them. A virtual machine is an external system, which does not depend on TrueConf application. Its configuration and support are entirely user’s responsibility.

Step 1: Check Hardware Virtualization Support

In this case, Hyper-V virtualizer is a hardware virtualization tool, which uses special processor architecture for virtualization. Accordingly, it cannot be launched on some processors where this architecture is not available.

To check if your hardware supports hardware virtualization, enter the following command in the terminal:

egrep ‘(vmx|svm)’ /proc/cpuinfo

If output is not empty, as in the picture below, hardware virtualization is most likely to be supported.

Step 2: Install KVM

To begin, update your system and packages:

$ sudo apt-get update && sudo apt-get upgrade –y

Now install necessary packages:

$ sudo apt-get install ubuntu-virt-server python-vm-builder kvm-ipxe –y

Check that the current entry belongs to libvirtd group:

$ cat /etc/group | grep libvirtd

Here is a typical command output if the group contains 111 group and andrey as a user:

libvirtd:!:111:andrey

If there is no current user in the group, you can add it with a separate command:

$ sudo adduser id -un libvirtd

Adding user ‘andrey’ to group ‘libvirtd’ …

Adding user andrey to group libvirtd

Done.

Then, log in again and check KVM launching:

$ sudo virsh -c qemu:///system list

KVM is launched, but output is empty, as your virtual machine has not been created yet — it will be created during the next steps.

Step 3: Create Network Bridge

Next, create a network bridge. This may require editing /etc/network/interfaces file.

This file contains a line specifying the main network interface. It comes after the line-comment “# The primary network interface”. If eth0 is network interface (a line contains “auto eth0”), it should be replaced with br0 and four new lines should be added to the end of file:

bridge_ports eth0
bridge_stp off
bridge_maxwait 0
bridge_fd 0

The picture below shows an example of such editing, but instead of replacing “auto eth0” line, we’ve commented on it (we’ve added a hash sign in the beginning to ignore this line) and added a new one after it (with an additional comment before it).

After that, restart the network or even the entire operating system:

$ sudo /etc/init.d/networking restart

$ sudo shutdown –r now

Step 4: Configure Network Gateway

To configure a gateway, edit one more file — mc/etc/sysctl.conf. Find and uncomment the following line in this file:

net.ipv4.ip_forward=1

After that, enter the command to apply changes and restart the OS again:

$ sudo sysctl -f

$ sudo shutdown –r now

Step 5: Create a Virtual Machine

To create a virtual machine, run the following commands:

$ apt-cache search virt-install

virtinst — Programs to create and clone virtual machines

$ apt-cache search virt-viewer

virt-viewer — Displaying the graphical console of a virtual machine

$ sudo apt-get install virtinst virt-viewer –y

$ sudo virt-install -n UServer -r 1024 -f /var/lib/libvirt/images/server.img -s 10 -c /var/lib/libvirt/images/ubuntu-12.04.4.iso –accelerate –os-type=linux –os-variant=generic26 –graphics vnc,listen=0.0.0.0 -w bridge:br0 –v

The last of these commands contains a large number of parameters which are of the following purpose:  

  • -n Userver is a virtual machine name;
  • -r 1024 is an allocated RAM capacity;
  • -f server.img is a file that is a virtual hard disk for a guest OS;
  • -s 10 is a disk capacity in gigabytes;
  • -c ubuntu-12.04.4.iso is a distribution disk image of a guest OS, which connects as a virtual cdrom;
  • –accelerate –os-type=linux –os-variant=generic26 -v is additional parameters for optimizing a virtual machine and leveraging virtualization hardware capabilities;
  • –graphics vnc,listen=0.0.0.0 is a vnc server launch for a virtual machine without reference to any network interface
  • -w bridge:br0 is a network bridge used.

Now you can check a list of launched virtual machines:

$ sudo virsh -c qemu:///system list

Now install necessary packages in the system:

$ sudo apt-get install xtightvncviewer

and test TCP connections:

tcp 0 0 0.0.0.0:5900 0.0.0.0:* LISTEN 15 54/qemu-system-x8

Step 6: Connect to KVM and Install Server

Now you can connect to KVM from anywhere on the network. Download UltraVNC Viewer:

and use it to install Windows Server 2008:

$ sudo virt-install -n UServer4 -r 1024 -f /var/lib/libvirt/images/server4.img -s 15 -c /var/lib/libvirt/images/win2008.iso –accelerate –os-type=windows –os-variant=win2k8 –graphics vnc,listen=0.0.0.0 -w bridge:br0 -v

In the future, you can launch a virtual machine from the terminal with the following command:

$ virsh start UServer4

UServer4 is a virtual machine name here.

Step 7: Install TrueConf Server

Once virtual machine has been successfully configured, just install TrueConf Server and get started. With our guide, it takes only 15 minutes.