Wednesday, January 8, 2025
Google search engine
HomeGuest BlogsHow To Install KVM Hypervisor on Ubuntu 22.04|20.04

How To Install KVM Hypervisor on Ubuntu 22.04|20.04

.tdi_3.td-a-rec{text-align:center}.tdi_3 .td-element-style{z-index:-1}.tdi_3.td-a-rec-img{text-align:left}.tdi_3.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_3.td-a-rec-img{text-align:center}}

In this guide, you will learn to Install KVM Hypervisor Virtualization server on Ubuntu 22.04|20.04 Linux system. KVM (Kernel-based Virtual Machine) is a free and open source virtualization solution for Linux Systems running on x86 hardware. It requires the server to have CPU virtualization extensions (Intel VT or AMD-V).

Check the link for installation of KVM on Fedora, RHEL/CentOS 8

KVM consists of a loadable kernel module,kvm.ko, that provides the core virtualization infrastructure and a processor specific module, kvm-intel.ko or kvm-amd.ko.

.tdi_2.td-a-rec{text-align:center}.tdi_2 .td-element-style{z-index:-1}.tdi_2.td-a-rec-img{text-align:left}.tdi_2.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_2.td-a-rec-img{text-align:center}}

Step 1: Install KVM / QEMU on Ubuntu

Here are the steps to follow when installing KVM Virtualization tool on Ubuntu Linux machine. All KVM packages for Ubuntu are available on upstream repositories. The apt package manager is used for all packages installation.

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

Aso install other useful Virtual Machine management tools.

sudo apt -y install virt-top libguestfs-tools libosinfo-bin  qemu-system virt-manager

Ensure the vhost_net module is loaded and enabled.

$ sudo modprobe vhost_net 
$ lsmod | grep vhost
vhost_net              24576  0
tun                    49152  1 vhost_net
vhost                  49152  1 vhost_net
tap                    28672  1 vhost_net

$ echo vhost_net | sudo tee -a /etc/modules 

This will give you tools similar to Linux ls, cat, top command for use with Virtual Machines.

Step 2: Create KVM Bridge on Ubuntu

For your Virtual Machines to talk to the outside world, a Linux bridge is required. Installation of KVM on Ubuntu 22.04|20.04 creates a Linux bridge called virbr0. This can be used for all test environments.

But if you want to your VMs to be accessible over the network, you’ll need to create a bridge on physical network interface attached to your machine.

Create one on your Debian server/workstation like below.

sudo nano /etc/network/interfaces

My bridge configuration uses a network interface (ens33) to create a Linux bridge called br1. Replace the values provided with yours.

# Primary network interface
auto ens33
iface ens33 inet manual

# Bridge definitions
auto br1
iface br1 inet static
bridge_ports ens33
bridge_stp off
address 172.16.54.149
network 172.16.54.0
netmask 255.255.255.0
broadcast 172.16.54.255
gateway 172.16.54.2
dns-nameservers 172.16.54.2

Reboot your machine for the network configuration changes to take effect.

sudo reboot

Confirm IP network details.

$ ip addr

See screenshot below.

KVM Bridge Debian

Step 3: Create Virtual Machine on KVM

You can use Virtual Machine Manager GUI to create an instance on KVM or via virt-install command line tool.

For virt-install, installation snippet is shared below.

sudo virt-install \
  --name de11 \
  --ram 2048 \
  --vcpus 2 \
  --disk path=/var/lib/libvirt/images/deb11.qcow2,size=20 \
  --os-type linux \
  --os-variant debian10 \
  --network bridge=br1 \
  --graphics none \
  --console pty,target_type=serial \
  --location 'http://ftp.debian.org/debian/dists/bullseye/main/installer-amd64/' \
  --extra-args 'console=ttyS0,115200n8 serial'

This will download kernel and initrd image before starting installation.

deb installer kvm

The installation process will start shortly. Follow installation prompts for Debian system on KVM.

deb installer kvm 02
deb installer kvm 03

We also have a guide on:

More guides on Ubuntu:

Also check related KVM articles:

.tdi_4.td-a-rec{text-align:center}.tdi_4 .td-element-style{z-index:-1}.tdi_4.td-a-rec-img{text-align:left}.tdi_4.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_4.td-a-rec-img{text-align:center}}

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments