Ubuntu Virtual Machines (VMs)

Ubuntu Virtual Machines (VMs)


Info and prerequisites

KVM (Kernel-based Virtual Machine) is the Linux version of a Hypervisor. Compared to its rivals VMware ESXi/Workstation, Oracle VirtualBox and Microsoft’s own Hyper-V it is a pared down offering without many of the features that its counterparts offer, as far as I have seen. What it lacks in features it more than makes up for in ease-of-use. I first heard of a Linux variant of a hypervisor through watching Wendell on the Level1Techs YouTube channel. Though they didn’t go into the details of how to configure this kind of setup – in the videos that I have seen – they did put the seed in my brain. Once I had a spare computer powerful enough to make it worthwhile I had a dig around to see what I could come up with.

First things first, KVM will only work if your CPU has hardware virtualization support – either Intel VT-x or AMD-V. If this option is not available to you in your BIOS/UEFI then you are not going to get any further in this endeavour.

If you already have Ubuntu installed (I am running Server 17.04 at time of writing) then you can check whether your system is compatible by running the following:

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

If you are returned a 0 then, unfortunately, this means your CPU does not support hardware virtualization. Any number other than 0 means that virtualization is supported. Bear in mind that even if your computer output is something other than 0 you may still have to ensure that you have enabled VT-x or AMD-V correctly in the BIOS/UEFI but this output is telling you that virtualization will be supported. The output from this command indicates how many cores or threads your processor is able to run.

For example, my 4 core non-hyperthreaded Core i5 3570K outputs:
root@localhost:~# egrep -c '(svm|vmx)' /proc/cpuinfo
Whereas my 8 core hyperthreaded Ryzen 7 1800X outputs:
root@localhost:~# egrep -c '(svm|vmx)' /proc/cpuinfo

If you are looking to go further and assign VMs specific hardware then your system will need to support VT-d. This is not to be confused with VT-x/AMD-V which is specifically about CPU support for virtualization. At the moment VT-d eludes me so I am not going to go into it here but it can allow you to do some very cool things. For example, if you are looking to have a Windows VM that you can use to game that is running on a Linux KVM then this is what you will need to allow the Windows VM to utilise the GPU along with the ability to provision specific USB ports to pass through the connectivity required for the keyboard and mouse. Watch this YouTube video for a good idea of what that could mean at the extreme end of things.

Setting up Ubuntu to host Virtual Machines (VMs)

First thing to do with your server is to install all the required packages:

root@localhost:~# sudo apt-get install qemu-kvm libvirt-bin virtinst bridge-utils cpu-checker

Once these packages are all installed you can check whether KVM is in, working and you are ready to start creating VMs. To check that you need to issue the following command:


For example:

root@localhost:~# kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used

If you see the above output then you are good to go.

Next we have to configure the network bridge, we installed the required bridge-utils package already so we just need to edit the network config to get this working so load up /etc/network/interfaces into your editor of choice. I commented out some of the existing config and added some to leave the following (changes are in bold italic):

auto lo
iface lo inet loopback

# The primary network interface
#auto enp3s0
#iface enp3s0 inet dhcp
# This is an autoconfigured IPv6 interface
#iface enp3s0 inet6 auto

auto br0
iface br0 inet dhcp
bridge_ports enp3s0
bridge_stp off
bridge_fd 0
bridge_maxwait 0

This should give you an idea of what to do but I think you are best off looking at the NetworkConnectionBridge guide in the Ubuntu Documentation

As you can tell, this guide is by no means finished. I will add more content to this...soon(ish)...

If you need a new website or your website needs updating go to https://10kinds.tech.

10 Kinds Technology
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram