If you've ever worked on coding projects, DevOps tasks, or even computing experiments, you've probably used virtual machines. From experimenting with wacky ideas to tinkering with different operating systems, there are plenty of reasons to use virtual machines. Sure, they tend to require more resources than containers, but their superior isolation provisions make them ideal for demanding tasks.

On Windows, you'd probably use something along the lines of VirtualBox or VMware Workstation Pro when you're a beginner, before moving on to Hyper-V for hardcore projects. The Linux landscape has just as many options for running virtual machines. But after tinkering with different hypervisors on Linux laptops, PCs, and mini-PCs, I've eventually switched to KVM as my preferred hypervisor. While it may seem somewhat cumbersome to use upon first glance, it works exceedingly well once I pair it with the easy-to-use Virt-Manager.

KVM meshes well with general-purpose Linux distros

It packs a lot more features than VirtualBox

Like Windows, Linux also supports VirtualBox, though the limitations of the Type-2 hypervisor become apparent once you get into complex workloads. Performance-wise, it leaves a lot to be desired, while PCI passthrough is non-existent and clustering was removed from the hypervisor ages ago.

Meanwhile, KVM is a Type-1 hypervisor that’s built into Linux and relies on kernel modules to run virtual machines. As such, it provides much better performance when running virtual machines than its Type-2 counterparts. It can also pass GPUs, NICs, and other PCIe devices to virtual machines. Since it's deeply integrated into the Linux kernel, KVM is nowhere near as resource-intensive as its Type-2 counterpart, and can essentially run on a system with as little as 1GB of RAM. Heck, it’s even more lightweight than the Xen hypervisor, which requires twice as much memory. I've also used Xen for virtualization workloads, and while it's an amazing tool in its own right, KVM has always performed better - especially on low-end systems.

And it's just as easy to install

As someone who has spent most of his youth with VirtualBox, I was a bit terrified of KVM when I first attempted to set up the hypervisor a few years ago. After all, I’d dealt with my fair share of package conflicts and dependency issues when running hardcore development tools in the past. Luckily, installing ESXi is a complete cakewalk, as a single command can grab the packages and set them up on most Linux distributions:

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

Afterward, you'll want to enable libvirtd with a couple of commands:

sudo systemctl enable libvirtd
sudo systemctl start libvirtd

You can technically dive right into the KVM rabbit hole using a couple of commands, but I wouldn’t recommend doing so unless you’re an advanced DevOps or sysadmin learner. Sure, you could run the virt-install command alongside vcpus, memory, and other arguments to deploy a virtual machine, and use the SPICE remote display utility to access it. But managing multiple VMs from a command-line interface can be a royal pain. Luckily, there’s another tool that provides a sleek UI for controlling KVM-based virtual machines.

Virt-Manager provides the configuration GUI

A minimalist interface that includes all essential VM settings

Virt-Manager serves as the quintessential part of my KVM utility belt, and installing it is as simple as running sudo apt install virt-manager -y. Its UI is a lot cleaner than VMware Workstation Pro’s, though it includes all the VM management options I can ask for. There’s the VM creation utility, which provides a menu-based interface for configuring virtual machines. Under the hood, it uses the virt-install command to initialize VMs, thereby sparing me the hassle of manually setting up the right arguments.

Then there’s the Connection details section, which provides the essential Network and Storage options for my KVM-based virtual machines. Meanwhile, the Details tab inside the VM lets me modify the boot order as well as pass I/O components (including PCI devices), TPM modules, serial display units, and several other devices to my virtual machines. Since I prefer editing config files when managing multiple VMs, I’ve enabled the option to modify XML files for my virtual machine stack.

In case you run into network issues when booting your virtual machine, you'll want to enable the network bridge by running the sudo virsh net-autostart default command.

There’s a reason why virtualization platforms use KVM

Although I often use KVM on my general-purpose Linux systems, it's hands-down the most important aspect of my home lab. That’s because Proxmox – the virtualization platform running on the majority of the server nodes in my house – relies on KVM for its VM-hosting magic. Likewise, I use a TrueNAS Scale storage server, which also uses KVM to run virtual machines (though I tend to prefer containers to VMs on my NAS). Harvester, too, relies on this amazing hypervisor, while my favorite underrated NAS distro, OpenMediaVault, also includes a KVM plugin. As such, you'll find KVM practically everywhere in the Linux server ecosystem.