Jump directly to main content

Setup QEMU/KVM virtualisation



Virtualisation is the act of creating a virtualised computer (guest), inside another computer (the host) by sharing the hardware. This allows a single host the ability to run all your services, whilst keeping a level of SoC.

Enable in the BIOS

To run virtual machines, certain flags in the bios need to be set. If you don't want to bring down an existing server to check, then check the next section first.

Check Virtualisation is enabled

Double check to make sure your server can be used for virtualisation, if you've enabled it in the BIOS it should be good. Just run one of the following command

lscpu | grep 'Virtualization'
grep -E --color '(vmx|svm)' /proc/cpuinfo

Install the packages

The easiest part, just copy and paste the below to install the required packages.

sudo apt install qemu-kvm libvirt-clients libvirt-daemon libvirt-daemon-system virtinst

Sessions

There are two different session types for VMs, user, and system sessions. If you are using a desktop, and intend to virtualise other desktop OSs I recommend user sessions. If you're setting up a server hypervisor, then use System sessions.

User Session

A user session VM is what I recommend for personal PCs, laptops, etc. as it's the best option for desktop virtualisation (e.g. a Kali install for l33t hackers).

Add user to group

sudo adduser $USER libvirt

Enable default network

Check the name of your default network (typically just 'default').

sudo virsh net-list --all

Enable the network.

sudo virsh net-start default

(Optionally) Set it to turn on with system boot.

sudo virsh net-autostart default

System Session

For now all that's needed to know is that you run sudo before any virsh commands, and that the VMs will launch with root permissions.

Extra

Setup bridge adapter for KVM

Optimisations for KVM Virtual Machines