
Setting up KVM (Kernel-based Virtual Machine) on Debian 12 Bookworm provides a powerful virtualization solution, allowing you to run virtual machines efficiently. Before you begin, it’s crucial to ensure your system’s CPU supports hardware virtualization. You can check for Intel VT-x or AMD-V support by looking for the vmx or svm flags in the output of lscpu
. If these flags are present, your hardware is compatible.
The installation process starts by ensuring your package list is up-to-date. Open a terminal and run sudo apt update && sudo apt upgrade -y
.
Next, install the core KVM and virtualization packages. The essential packages include qemu-kvm, the machine emulator; libvirt-daemon-system, the daemon providing the libvirt API; libvirt-clients, the client-side tools; and bridge-utils, useful for network bridging. Install them with the command:
sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils -y
For a graphical interface to manage your virtual machines, install virt-manager:
sudo apt install virt-manager -y
After installation, the libvirt service should start automatically. You can verify its status using systemctl status libvirtd
. Ensure it is active and running. To start or enable it if necessary, use sudo systemctl start libvirtd
and sudo systemctl enable libvirtd
.
To manage virtual machines as a regular user without needing sudo
constantly, you must add your user account to the libvirt group. Replace your_username
with your actual username:
sudo usermod -aG libvirt your_username
You will need to log out and log back in for this change to take effect.
Finally, verify that KVM is correctly loaded and libvirt can see the virtualization capabilities. You can use the virsh
command, a command-line interface for libvirt. Running virsh list --all
should not return any errors related to connecting to the hypervisor and should list any virtual machines (even if none exist yet).
With these steps completed, your Debian 12 system is configured for running virtual machines using KVM. You can now create and manage VMs using virsh
, virt-manager
, or other libvirt compatible tools. Basic network configuration, often involving setting up a network bridge, is typically the next step before launching your first guest operating system.
Source: https://kifarunix.com/install-kvm-on-debian-12/