Skip to main content

Installing KVM, QEMU, and libvirtd on Debian

KVM (Kernel-based Virtual Machine) is a virtualization module in the Linux kernel that allows the kernel to function as a hypervisor. QEMU is a generic and open-source machine emulator and virtualizer. libvirtd is the management service that allows you to control virtualization technologies, such as KVM and QEMU, via a unified interface.

This tutorial will guide you through the installation and setup of KVM, QEMU, and libvirtd on a Debian system.

Step 1: Check CPU Virtualization Support

Before installing KVM, ensure your CPU supports virtualization and that it is enabled in your BIOS. You can check this by running:

egrep -c '(vmx|svm)' /proc/cpuinfo
  • If the output is 0, your CPU does not support hardware virtualization.
  • If the output is 1 or more, your CPU supports hardware virtualization.

Step 2: Install Required Packages

Install the necessary packages for KVM, QEMU, and libvirtd:

sudo apt-get install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager
  • qemu-kvm: KVM and QEMU package.
  • libvirt-daemon-system: The libvirt daemon, which provides the management layer.
  • libvirt-clients: Provides command-line utilities for managing virtualization.
  • bridge-utils: Used for configuring network bridges.
  • virt-manager: A desktop interface for managing virtual machines.

Step 3: Enable and Start libvirtd

Enable and start the libvirtd service to ensure it runs on system boot and starts immediately:

sudo systemctl enable --now libvirtd

Step 4: Check libvirtd Status

Verify that libvirtd is running:

sudo systemctl status libvirtd

You should see a status indicating that the service is active (running).

Step 5: Add Your User to Required Groups

Add your user to the libvirt, kvm, and libvirt-qemu groups to allow management of virtual machines without needing root privileges:

sudo adduser $USER libvirt
sudo adduser $USER kvm
sudo adduser $USER libvirt-qemu

After adding your user to these groups, log out and log back in for the changes to take effect.

Summary

By following these steps, you have installed KVM, QEMU, and libvirtd on your Debian system. You are now ready to create and manage virtual machines. Use virt-manager for a graphical interface to manage your VMs or virsh for command-line management.

Additional Notes

  • virt-manager: You can start virt-manager from your application menu or by typing virt-manager in the terminal. This tool provides a graphical interface for creating, managing, and interacting with virtual machines.
  • virsh: This is a command-line tool to manage VMs. For example, you can list all virtual machines with virsh list --all.

These tools and steps will help you set up a powerful and flexible virtualization environment on your Debian system.