Linux VPS

Install KVM on Ubuntu Server with libvirt and virt-manager

Install KVM on Ubuntu step by step: check VT-x/AMD-V support, install QEMU, libvirt and tools, add your user to the right groups, create a network bridge and verify the setup.

IntermediateUbuntu servers3 min read

KVM turns the Linux kernel into a hypervisor, and with QEMU and libvirt you get a complete virtualization stack for free. This guide shows how to install KVM on Ubuntu Server 22.04 or 24.04 so you can run your own virtual machines on a dedicated server or home lab.

Before you start

  • A physical server or dedicated machine running Ubuntu Server 22.04 or 24.04 with sudo access. A normal VPS usually cannot run KVM unless the provider enables nested virtualization.
  • Intel VT-x or AMD-V enabled in the BIOS/UEFI.
  • Console or IPMI access in case network changes cut SSH.

Check CPU virtualization support

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

A number above 0 means the CPU supports it. Install the checker for a clearer answer:

sudo apt update && sudo apt install -y cpu-checker && kvm-ok

You want to see KVM acceleration can be used. If not, enable virtualization in the firmware.

Install KVM on Ubuntu

sudo apt install -y qemu-kvm libvirt-daemon-system libvirt-clients virtinst bridge-utils
  • qemu-kvm: the emulator using KVM acceleration.
  • libvirt-daemon-system: the libvirtd management service.
  • virtinst: provides virt-install for creating VMs.

Enable and check the service:

sudo systemctl enable --now libvirtd
sudo virsh list --all

Add your user to the libvirt groups

sudo usermod -aG libvirt,kvm $USER

Log out and back in so the groups apply. You can then run virsh without sudo.

Create a network bridge for VMs

libvirt's default NAT network (virbr0) lets VMs reach the internet but not be reached from outside. For public IPs, bridge the main interface. Edit your Netplan file, for example /etc/netplan/01-netcfg.yaml:

network:
  version: 2
  ethernets:
    eno1:
      dhcp4: false
  bridges:
    br0:
      interfaces: [eno1]
      addresses: [203.0.113.10/24]
      routes:
        - to: default
          via: 203.0.113.1
      nameservers:
        addresses: [1.1.1.1, 8.8.8.8]

Replace the interface name and addresses with yours, then apply from the console with sudo netplan try, which rolls back automatically if you lose connection. See static IP with Netplan for more Netplan detail.

Verify the installation

  1. lsmod | grep kvm shows kvm_intel or kvm_amd.
  2. virsh net-list --all shows the default network.
  3. ip a show br0 shows the bridge with your IP.

Optional: install virt-manager on your desktop and connect over SSH (File → Add Connection) for a graphical view.

Troubleshooting

  • kvm-ok says acceleration cannot be used: enable VT-x/AMD-V (sometimes called SVM or Intel Virtualization Technology) in firmware and fully power-cycle.
  • Permission denied on /var/run/libvirt/libvirt-sock: your session lacks the libvirt group; log in again.
  • Lost SSH after netplan apply: use the console to fix the YAML; always test with netplan try.

Frequently asked questions

Can I install KVM on a VPS?

Only if the provider exposes the vmx/svm CPU flag through nested virtualization. Most do not by default.

Do I need a desktop environment?

No. Manage VMs with virsh and virt-install, or remotely with virt-manager or Cockpit.

Is KVM free?

Yes. KVM, QEMU and libvirt are open source and included in Ubuntu's repositories.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.