January 18, 2021



Debian – How to install KVM virtualization

virtual-dvd-drive-iconKVM virtualisation is a Kernel based virtualisation. It actually stands for Kernel-based Virtual Machine. It means that each of your virtual machine will have it´s own virtual hardware, such as network card, graphic card, memory and hard drive.

To setup KVM virtualisation it require a multicore cpu. And virtualisation needs to be activated in the BIOS. Look for virtualisation, Intel VT-x (vmx) or AMD-v settings, and enable it. You might be able to install KVM without virtualisation enabled in the BIOS. But the virtual machines will be extremely slow.

Here is how to install KVM on a minimal Debian installation.

First we assume a ssh server is installed, and sudo.

Step 1:
First we install the essential packages for KVM.
apt-get install kvm libvirt-bin virtinst bridge-utils

If you want to be able to controll the virtual machines from your own users instead of root. Add your user to the libvirt group.
adduser john libvirt

Step 2:
To be able to give network access to your virtual computers you will need to bridge your network card. To do this we will change the network interface file. (Change the ip´s to match your network)
nano /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
iface eth0 inet manual

# Initial bridge
auto br0
iface br0 inet static
bridge_ports eth0

Now you need to reboot your system and verify you can access from ssh and that it has the network accesses you need.

Check out my previous article about how to install libvirt manager on how to create and control the virtual machines.

That´s it for installing KVM on a Debian.

Happy virtualisation!