Last Updated on 2 weeks by Sachin G
KVM (Kernel-based Virtual Machine) is a popular virtualization technology that allows multiple virtual machines into a single hardware machine each of which is the independent operating system. In this article you will be able to install KVM on the Ubuntu operating system, After KVM setup, you can host virtual machines. In Ubuntu, you can manage KVM from the command line with the virsh utility as well as graphical with web console virtual machine tool.
Prerequisites
Before you begin, you will need the following:
- A Ubuntu 24.04 server with at least 2GB of RAM with Extra RAM for your virtual machines.
- A working SSH client.
- 6 GB Disk Space and Additional for Virtual Machine as you require.
- Intel or AMD processor virtualization extensions are supported.
Here are the steps to determine whether your CPU supports virtualization extensions. Retrieve the svm or vmx CPU flag, which serves as an indicator of virtualization support on the host machine. The svm flag signifies the presence of AMD-V extensions on an AMD processor, while the vmx flag indicates virtualization support on an Intel processor. These flags play a crucial role in verifying the compatibility of your CPU with virtualization technologies.
grep -E ‘svm|vmx’ /proc/cpuinfo
Update and upgrade the Software Package
Update and upgrade the index package and install the latest version of the installed package. To do this run the below following commands.
# sudo apt-get update; sudo apt-get upgrade -y
Verify the KVM modules :
As an extra step, make sure to check if the computer’s kernel has the required kvm modules loaded by using the following command :
# lsmod | grep kvm
In the screenshot above, you can see that the module “kvm_intel” is loaded. Typically, the output can show either “kvm_intel” or “kvm_amd.”
Installing KVM
To install KVM, run the following commands:
sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager virtinst -y
Starting and Enabling KVM
Once KVM is installed, you need to enable it. To do this, run the following command:
sudo systemctl enable –now libvirtd
libvirtd daemon should run after the start and enable the service. Verify the status after running the services.
sudo systemctl status libvirtd
Validate System Host virtualization setup
Make sure to check if your virtualization setup has everything you need before creating a virtual machine. This utility validates that the system host is configured in a perfect way to run libvirt hypervisor drivers.
# virt-host-validate
At last, you should add current users to the KVM and libvirt groups so logged-in users can manage virtual machines through the command line as well as the graphical interface. The below commands will help you to add users.
sudo usermod -aG kvm $USER
sudo usermod -aG libvirt $USER
After adding a user, you should log out and log in from the current user to make changes in the environment.
Browse KVM Virtual Machines Manager
By virsh command line utility or virtue-manager GUI tools or search in the Ubuntu search console ‘Virtual machine Manager’ and open the tool and manage your virtualized machines.
With KVM, now you can easily create and manage virtual machines, and you can use them for a variety of purposes, such as development, testing, and production. Here is one post to add the disk on KVM virtual machine.
I am a professional freelance contributor and the founder of Tech Transit. I hold certifications in Linux, Ansible, and OpenShift from Red Hat, as well as CPanel and ITIL certifications. With a passion for education, culture, and community, I love writing and sharing knowledge. Since 2009, I’ve been actively using, setting up, supporting, and maintaining Linux systems. Linux truly rocks!