Set Up Ubuntu 16.04 KVM Server
This tutorial will turn your baremetal Ubuntu 16.04 server into a KVM host. This tutorial will just cover installation, but feel free to read my other KVM tutorials as and when you need them, such as for installing guests and setting up a network bridge.
For the time being, you need a dedicated server, or your own physical machine. You cannot setup a KVM Hypervisor on a VPS, such as a Digital Ocean or AWS EC2 instance.
- libvirtd (libvirt) 1.3.1
- QEMU emulator version 2.5.0 (Debian 1:2.5+dfsg-5ubuntu10.14)
First, let's check that the machine you are trying to set up as a KVM host is compatible:
sudo apt-get install cpu-checker -y kvm-ok
- Alternatively, run
egrep -c '(svm|vmx)' /proc/cpuinfoand if it returns a number greater than 0, you should be fine.
sudo apt-get install qemu-kvm libvirt-bin bridge-utils virtinst -y
Note: You will also need virt-viewer if you want to install via VNC another day.
At this point we have a choice of creating a new user to manage the KVM virtual machines, or to make the current logged in user the manager. Pick one.
Please choose one of either of the options below:
Option 1 - Make Current User KVM Manager
sudo usermod --append --groups libvirtd $USER
Option 2 - Create KVM User
Add a subuser with sudo priviledges and a home directory:
KVM_USER="kvm_user" sudo useradd -d /home/$KVM_USER -m $KVM_USER sudo passwd $KVM_USER echo "$KVM_USER ALL=(ALL:ALL) ALL" | sudo tee --append /etc/sudoers
adduser $KVM_USER command instead of
useradd as this will automatically prompt you for a password and set up a home directory
Add the kvm user to the libvirtd group
sudo usermod --append --groups libvirtd $KVM_USER
Log in as the kvm user. All commands from here on will be executed within this account.
Check the Installation
Check that installation went okay by running the following command:
sudo virsh -c qemu:///system list
Which should output:
Id Name State ----------------------------------------------------
You now have a working KVM Host on which you can deploy virtual machines. I now suggest you read my getting started with KVM article so that you can quickly start deploying your own virtual machines with little to no effort/research.
Please refer here.
First published: 16th August 2018