Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Install Debian 12 KVM Server

This tutorial will show you how to set your Debian 12 server up as a KVM host.

Related Posts

Version Info

  • libvirtd (libvirt) 9.0.0
  • QEMU emulator version 7.2.7 (Debian 1:7.2+dfsg-7+deb12u3)


Run the command below to check if system supports KVM. You should see a number greater than 0.

egrep -c '(svm|vmx)' /proc/cpuinfo

Install most of the necessary packages.

sudo apt-get install \
  --no-install-recommends \
  qemu-kvm qemu-utils libvirt-clients libvirt-daemon-system virtinst

Because I am likely to run a bridge from the host, I also make sure to install the bridge-utils package

sudo apt-get install bridge-utils -y

Virtinst Package

We used to have to manually install the virtinst package, but now it is automatically included. I am including this here just in case we ever need to manually install it again. However, feel free to skip this section.

We now wish to install the virtinst package so that we can install guests with the virtinstall command.
Unfortunately, this comes with the recommendation of the virt-viewer package which would require a lot of the GUI based packages. Thus, depending on whether you are runnning a headless or a Desktop KVM host, pick one of the following two options:

Headless KVM Hosts:

sudo apt-get install --no-install-recommends virtinst -y

# Now install its recommendations, except virt-viewer
sudo apt-get install \
  libosinfo-l10n python-gi-cairo python-setuptools python-cryptography \
  python-idna python-openssl python-socks python-ntlm \
  python-cryptography python-idna python-ipaddress python-openssl -y

Desktop KVM Hosts: If you'r KVM host already has the GUI, then you probably want to just go ahead and install all the recommendations, which will include virt-viewer.

sudo apt-get install virtinst -y

Add User to Libvirt

Add your user to the libvirtd group so that you can run management commands without sudo.

sudo adduser $USER libvirt

Export Qemu Path

Without this, you will always end up having to run your virsh commands with sudo in order to see/manage your guests.

echo 'export LIBVIRT_DEFAULT_URI=qemu:///system' >> $HOME/.bashrc


Check that everything is fine by running:

sudo virsh -c qemu:///system list

You should see the following output:

 Id    Name                           State

Setting Up Default Network

Debian 12 won't automatically install, or perhaps not autostart a default network. You probably want to create one.

Last updated: 13th December 2023
First published: 13th December 2023