KVM hypervisorOctober 16, 2021 | Stack
There is a lot of different hypervisors and virtual machine managers out there. After using a commercial Type-2 hypervisor for many years, I have started to use KVM whenever possible.
What is KVM?
KVM is native to all linux systems today, it works directly on the kernel level and is considered as a Type-1 hypervisor. So, due to the fact that it is open source and free, works directly on the kernel and native to Linux, this should be an obvious choice if on a Linux system.
There is a Virtual Machine Manager (GUI). We'll install it later in this post.
In datacentres OpenStack cloud platform, makes use of KVM to make provisioning.
Multipass is the recommended methode to create Virtual Machines on a workstation. If you have worked with Docker, the ressemblance is close.
Depending on your OS, the libraries need to work with KVM will differ. You also need to make sure that you CPU supports Virtualisation (most Intel and AMD from 2015+ do).
The libraries to use will differ depending on the OS you use. You also has to make sure that your CPU supports Virtualisation (most Intel, AMD > 2015 do).
On Ubuntu install the following libraries:
sudo apt -y install bridge-utils cpu-checker libvirt-clients libvirt-daemon qemu qemu-kvm
Make sure that your CPU supports virtualisation:
egrep -c '(vmx|svm)' /proc/cpuinfo
It has to be > 0 to do so.
Check if you system can use KVM acceleration:
INFO: /dev/kvm exists KVM acceleration can be used
Verify the installation:
virsh list --all
an empty index should appear (Id, Name, State).
By default libvirtd is not enabled by default (at least if other hypervisors is installed), so you have to enable it:
sudo systemctl enable --now libvirtd
Install Virt Manager (GUI manager)
Most people if on a workstation probably also want a Graphical GUI, at least to begin with.
Install it with aptitude:
sudo apt install virt-manager
You may need to add you user to the following two groups:
sudo adduser [username] libvirt
sudo adduser [username] kvm
You might have to reboot after all of this and open virt-manager.
That is it and you have the best possible hypervisor out there, it may not have as many (often buggy) features as the commercial ones. But, it is almost running at bare metal speed and it just works!