How to Install QEMU KVM on Linux: Step-by-Step Guide

If you’re interested in running virtual machines on Linux with near-native performance, QEMU KVM is a powerful tool to achieve this. In this guide, we’ll cover the essential steps to properly install QEMU KVM, a Type 1 hypervisor that interacts directly with your machine’s hardware. Follow this guide to optimize your Linux system for virtual machines with KVM.

Verify CPU Virtualization Support

To run virtual machines on Linux with KVM, your CPU must support hardware virtualization. Here’s how to check:

Check Virtualization Capabilities
Run the following command to verify your CPU’s support:

lscpu | grep -i Virtualization
  • If your CPU supports virtualization, you’ll see VT-x for Intel CPUs or AMD-V for AMD processors.
  • If nothing appears, hardware virtualization may need to be enabled in your BIOS settings.

Ensure Kernel KVM Module Support

Next, make sure your Linux kernel includes KVM modules. The command differs depending on your distribution:

Arch Linux: zgrep CONFIG_KVM /proc/config.gz

Other Linux Distributions: CONFIG_KVM /boot/config-$(uname -r)

Update Your System

It’s best to start with a fully updated system.

  • For Arch Linux Users: sudo pacman -Syu
  • Install Yay for AUR Packages (Arch Only)
    If you’re using Arch Linux, you’ll need Yay to install additional packages. Run these commands in order.
  • sudo pacman -S --needed base-devel git
  • git clone https://aur.archlinux.org/yay.git
  • cd yay
  • makepkg -si

Install QEMU, KVM, and Dependencies

Once Yay is set up, install the QEMU/KVM suite along with Libvirt, Virt-Manager, and other necessary packages.

  • On Arch Linux: sudo pacman -S qemu-full qemu-img libvirt virt-install virt-manager virt-viewer edk2-ovmf swtpm guestfs-tools libosinfo
  • Install TuneD for Performance Optimization (Only ARCH)
    TuneD is a system tuning service useful for optimizing KVM. Install it with: yay -S tuned
  • On Debian or Ubuntu : sudo apt install qemu-system-x86 libvirt-daemon-system virtinst virt-manager virt-viewer ovmf swtpm qemu-utils guestfs-tools libosinfo-bin tuned
  • Fedora : sudo dnf install qemu-kvm libvirt virt-install virt-manager virt-viewer edk2-ovmf swtpm qemu-img guestfs-tools libosinfo tuned

Enable and Start Libvirt Daemon

Libvirt is essential for managing virtual machines. Enable and start the libvirt service:

sudo systemctl enable libvirtd.service

sudo systemctl start libvirtd.service

Optimize Host Performance with TuneD

To maximize KVM’s efficiency, TuneD provides pre-configured profiles for different workloads.

  1. Enable TuneD: sudo systemctl enable --now tuned
  2. Check Current Profile: tuned-adm active
  3. By default, it may show as balanced. To improve VM performance, switch to the virtual-host profile:
  4. List Available Profiles: tuned-adm list
  5. Set the Virtual Host Profile: sudo tuned-adm profile virtual-host
  6. Restart the System

Configure Network Bridge

By default, virtual machines are connected to a NAT network. You may need to manually activate this network.

  • Check Network Status: sudo virsh net-list --all
  • Start and Enable Autostart for Default Network:
  • sudo virsh net-start default
  • sudo virsh net-autostart default

Conclusion

Congratulations! You have successfully installed and configured QEMU KVM on Linux. You can now create virtual machines with Virt-Manager and experience nearly native performance.

Stay tuned for the next guide, where we’ll cover installing Windows 11 with 3D acceleration using KVM on Linux.

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

10 Important things to do Right After Installing Fedora 40

Next Post

Top 10 Things TO DO After Installing Manjaro

Related Posts