KVM is the Kernel-based Virtual Machine, built into Linux for x86 hardware. Your processor needs Intel VT or AMD-V extensions. Install QEMU and libvirt packages then add your user to the libvirt group. Commands below are untested samples from the Ubuntu documentation.
You want virtual machines on a Linux computer and need to know what KVM is and which packages to install. Your processor decides the answer.
This guide follows the KVM project page and the Ubuntu server documentation.
What is Linux KVM?
KVM project documentation describes KVM as a full virtualization solution for Linux on x86 hardware. It hosts multiple virtual machines including unmodified Linux or Windows guests and gives every virtual machine its own virtualized hardware. Linux merged the kernel component in version 2.6.20. See the KVM project page.
What are the Parts of KVM?
| Part | Role |
|---|---|
| kvm.ko | Loadable kernel module with the core virtualization infrastructure |
| kvm-intel.ko or kvm-amd.ko | Processor specific module |
| QEMU | Userspace component. KVM support sits in mainline QEMU since version 1.3 |
| libvirt | Management layer that Ubuntu documents for KVM |
How do You Check Hardware Support?
KVM needs x86 hardware with virtualization extensions from Intel (VT) or AMD (AMD-V). On many computers you must activate an option in the BIOS before the extensions work.
# Untested sample from the Ubuntu documentation
sudo apt install cpu-checker
kvm-ok
The kvm-ok command reports whether your processor has hardware virtualization.
How do You Install KVM on Ubuntu?
Ubuntu documents these steps in its libvirt guide.
- Update the package index.
- Install the qemu-kvm and libvirt-daemon-system packages.
- Add your user to the libvirt group.
- Log out and back in to apply the group membership.
- List virtual machines with virsh list.
# Untested sample from the Ubuntu documentation
sudo apt update
sudo apt install qemu-kvm libvirt-daemon-system
sudo adduser $USER libvirt
virsh list
Ubuntu states that members of the sudo group join the libvirt group automatically. Fresh installs show no running guests and no errors. System mode is the default on Ubuntu.
What Comes After the Install?
Create a guest with a management tool of your choice. This guide ends before guest creation because the sources above do not describe it. For a virtual disk format in Windows see how to create a VHD in Windows. For storage background see how cloud storage works.
Frequently Asked Questions
What is Linux KVM?
KVM is the Kernel-based Virtual Machine, a full virtualization solution for Linux on x86 hardware.
What Hardware does KVM Need?
KVM needs an x86 processor with virtualization extensions.
Which Linux Version Added KVM?
Linux merged the KVM kernel component into the mainline kernel in version 2.6.20.
Which Packages Install KVM on Ubuntu?
Ubuntu documents qemu-kvm and libvirt-daemon-system. Check hardware support first with kvm-ok.
Can KVM Host Windows Guests?
Yes. KVM project documentation lists unmodified Linux and Windows guests.
Key Takeaways
- KVM is virtualization built into Linux.
- Your processor needs Intel VT or AMD-V extensions.
- Ubuntu installs KVM with the qemu-kvm and libvirt-daemon-system packages.
- Add your user to the libvirt group and log in again.
- Command samples here are untested.
Sources and References
This guide follows the KVM project page and the Ubuntu server documentation.
- KVM project page linux-kvm.org
- Libvirt (Ubuntu server documentation) ubuntu.com