08 Jan 2020 - by 'Maurits van der Schee'
In a previous post I have installed OpenSSH (on Ubuntu 18.04) on my Dell R720xd. In this post I will show how to install KVM on it, so that you can start using it as a GNU/Linux hypervisor to run virtual machines. In this post I will also show how to load a graphical tool to connect to your KVM enabled server.
KVM requires CPU virtualization support (VT-x/AMD-V) to be enabled in the BIOS. You can check if your CPU is supported by installing cpu-checker and running the kvm-ok command.
sudo apt install cpu-checker -y kvm-ok
This should show:
INFO: /dev/kvm exists KVM acceleration can be used
If it does not then reboot, press F2 to enter the BIOS, enable the support and try again.
Now for the installation of the software
sudo apt-get install qemu-kvm libvirt-bin virtinst bridge-utils cpu-checker
You may also type
groups and verify that you are member of the
libvirt group. Before adding yourself log out and in to see if that adds you to the group. To test that the installation succeeded you can connect to the hypervisor by running:
virsh -c qemu:///system list
The output should be:
Id Name State ----------------------------------------------------
It is an empty list of virtual machines.
Now on your local computer (not on the server) install the virtual machine manager by running:
sudo apt install virt-manager
virt-manager and create a new connection towards your server. This should use SSH.
NB: You can even run virt-manager on Windows 10 using the Windows Subsystem for Linux (WSL).
osinfo-query os gets you a list of supported operating systems. You may have to install this utility first with:
sudo apt install libosinfo-bin
To see what the
os-variant values are for 3 longest supported Ubuntu versions, run:
osinfo-query --fields=short-id --sort=eol-date os vendor="Canonical Ltd" | tail -n 3
ubuntu14.04 ubuntu16.04 ubuntu18.04
To add the image to
sudo wget http://nl.archive.ubuntu.com/ubuntu-cdimage-xubuntu/releases/18.04/release/xubuntu-18.04.3-desktop-amd64.iso -P /var/lib/libvirt/boot
You may use the
virt-install command to install the latest Xubuntu on a 4 vCPU 8 GB RAM virtual machine, like this:
virt-install \ --name maurits-cloud \ --ram 8192 \ --disk path=/var/lib/libvirt/images/maurits-cloud.qcow2,size=256 \ --vcpus 4 \ --os-type linux \ --os-variant ubuntu18.04 \ --network network=default \ --graphics vnc \ --console pty,target_type=serial \ --cdrom /var/lib/libvirt/boot/xubuntu-18.04.3-desktop-amd64.iso
You can use the virtual machine manager to execute the (graphical) installation.
In the next post I will walk you through setting up serial console access from the KVM CLI to your virtual machines. This will allow you to quickly fix SSH connectivity issues in your VM or to enter a full disk encryption (LUKS) password. I will even explain how you can get access to the grub menu this way.