Thursday, March 5, 2026

KVM on Ubuntu

KVM (Kernel-based Virtual Machine) is a virtualization technology built into the Linux kernel that allows Linux to run multiple virtual machines (VMs) on a single physical server. KVM converts the Linux kernel into a Type-1 (bare-metal) hypervisor using CPU virtualization features.

In this blog post, I describe what KVM is and how to enable KVM on Linux Server. 

Main Linux virtualization components:

  • Linux kernel with KVM module
    • Modules: kvm.ko, kvm-intel.ko or kvm-amd.ko
    • Uses hardware virtualization (Intel VT-x / AMD-V)
  • QEMU
    • Provides hardware emulation.
    • Runs the VM process in userspace.
  • libvirt (optional but common)
    • Management API and tools (virsh, virt-manager)
  • Virtual devices
    • Disk: virtio-blk
    • Network: virtio-net
    • GPU: virtio-gpu 

Why KVM is powerful

  • Near bare-metal performance (hardware virtualization)
  • Part of Linux kernel (no separate hypervisor OS needed)
  • Open source
  • Used by many clouds and platforms

Examples of platforms built on KVM

  • OpenStack
  • Apache CloudStack
  • Proxmox VE
  • oVirt / Red Hat Virtualization
  • Google Compute Engine

Enable Linux Virtualization on Ubuntu Server

I have Ubuntu server in my home lab, so let's enable KVM on it.

Install KVM onto Ubuntu Server

KVM must be explicitly installed.  

sudo apt install qemu-kvm libvirt-daemon-system virtinst bridge-utils -y

Check if KVM works ...

kvm-ok

 root@acs-ubuntu-01:/home/dpasek# kvm-ok  
 INFO: /dev/kvm exists  
 KVM acceleration can be used  
 root@acs-ubuntu-01:/home/dpasek#   

Or other way to check kernel module ... 

lsmod | grep kvm 

 root@acs-ubuntu-01:/home/dpasek# lsmod | grep kvm   
 kvm_intel       487424 0  
 kvm            1409024 1 kvm_intel  
 irqbypass        12288 1 kvm  
 root@acs-ubuntu-01:/home/dpasek#  

Enable libvirt on Ubuntu Server

libvirt is a virtualization management API and toolkit used to control hypervisors such as KVM, QEMU, Xen, and others. libvirt provides a unified management layer for virtualization. Instead of controlling hypervisors directly, tools communicate with libvirt, which then controls the hypervisor (KVM).

Typical operations:

  • create virtual machines
  • start/stop VMs
  • configure CPU, RAM, disks
  • attach networks and storage
  • migrate VMs between hosts
  • monitor VM state 

Important libvirt components

libvirtd

The daemon running on the hypervisor host.

Responsible for:

  • controlling hypervisors
  • managing VM lifecycle
  • exposing API (local or remote)

Service:

systemctl status libvirtd

virsh

CLI tool to manage VMs.

Examples:

List VMs

virsh list --all

Start VM

virsh start vm1

Shutdown VM

virsh shutdown vm1 

Networking with libvirt

libvirt can manage:

  • Linux bridges
  • NAT networks
  • Open vSwitch
  • SR-IOV interfaces

Storage management

libvirt also manages storage pools:

  • directory
  • LVM
  • iSCSI
  • NFS
  • Ceph

Virtualization capabilities of the host system

Command ... 

virsh capabilities 

... displays the host’s virtualization features, supported guest types, CPU details, and hypervisor capabilities. The command prints a large XML document describing what the host can run.

Typical sections include:

  • Host CPU information
  • Supported virtualization types
  • Supported machine types
  • NUMA topology
  • Supported guest architectures 

Conclusion

This one is just a short blog post how to enable KVM on Ubuntu server, but I also do test 

  • Apache Cloud Stack as a Virtualization Management Platform of KVM hypervisors
  • OVN - Open Virtual Networking which is leveraging Open vSwitch as a data plane

Hope you find this one useful. 

 

No comments:

Post a Comment

KVM on Ubuntu

KVM (Kernel-based Virtual Machine) is a virtualization technology built into the Linux kernel that allows Linux to run multiple virtual mach...