What Is KVM?

Kernel-based Virtual Machine is a virtualization module in the Linux kernel that allows the kernel to function as a hypervisor.

Linux KVM

KVM (for Kernel-based Virtual Machine) is a full virtualization solution for Linux on x86 hardware containing virtualization extensions (Intel VT or AMD-V).
In the KVM model, a VM is a Linux process, scheduled and managed by the kernel. Linux scheduler allows fine-grained control of the resources allocated to a Linux process and guarantees a quality of service for a particular process. In KVM,

To understanding Linux KVM, it is important to an understanding of KVMs basic features. There are many useful advantages to using Linux KVM virtualization to deploy instances for internal growth or end user utilization such as:

  • Allocate More Memory Than Available
    Virtual machines can be allocated more memory than physically available on the hardware. This allows for the creation of more VMs.
  • Testing And Live Replication
    Test your live environment side by side
  • Private Networking
    Databses can be set up with only private access, allowing your publicaly accessable applications to make private calls to your databases.
  • Automatic NUMA Balancing
    This helps to improve performance.
  • Optimize Efficiency
    Creating virtual machines optimizes workflows and creates isolated environments for applications.

Install KVM On CentOS

Kernel-based Virtual Machine (KVM) is virtualization software for Linux. KVM will turn your server into a hypervisor.
Here, I will show you how to setup a virtualized environment with KVM in CentOS.


  • A system running Rhel/CentOS 7 or 8
  • An account with sudo privileges
  • Check if your system supports virtualisation:
    Intel cat /proc/cpuinfo | grep vmx
    cat /proc/cpuinfo | grep svm

STEP 1 – Install KVM

We need to install KVM tools to our system with the following command.

# sudo dnf -y update
# sudo dnf -y install qemu-kvm libvirt libvirt-python libguestfs-tools virt-install virt-top

Start and enable the libvirtd service.

# systemctl start libvirtd
# systemctl enable libvirtd

STEP 2 – Verify Installation

Now to verify the modules have been loaded, the following command will need to be run.

# lsmod | grep -i kvm

STEP 3 – Configure Network Bridge

By default dhcpd based network is configured automatically by libvirtd. You can verify this by issueing the following command:

# nmcli connection show
# virsh net-list
# virsh net-dumpxml default

Initially, virtual machines will only have access to other virtual machines on the same local network.
A private network will have been created by libvirt. The last command above can be used to verify it.

A bridge is necessary in order to  access other machines outside of the local network. To create a bridge, we need to know the NICs that are available. We can view this with the following command:

# sudo nmcli connection show

Take note of the DEVICE name and open the network file to edit it with your favourite text editor.

# vi /etc/sysconfig/network-scripts/ifcfg-[DEVICE-NAME]

Add the following line to the network file:


Now, we need to create the bridge.

vi /etc/sysconfig/network-scripts/ifcfg-br0

Enter the following values:

Add a bridge slave.

# sudo nmcli connection add type bridge-slave autoconnect yes con-name br1 ifname br1 master br0

Activate the bridge

# sudo nmcli connection up br0

STEP 4 – Create Virtual Machine

To create virtual machines, we will need an ISO image or 2.

# cd /var/lib/libvirt/iso/
# wgethttps://mirrors.edge.kernel.org/centos/8.3.2011/isos/x86_64/CentOS-8.3.2011-x86_64-boot.iso

Now we have an ISO, we can go ahead and create our virtual machine with virt-install.

# sudo virt-install --virt-type=kvm --name=centos8 --ram=2048 --vcpus=1 --os-variant=centos8.3 --file-size=30 --nonsparse  --cdrom=/var/lib/libvirt/iso/CentOS-8.3.2011-x86_64-boot.iso --network bridge=br0,model=virtio --graphics vnc

The following arguements are necessary for creating virtual machines.

--nameCustom name of the VM
--fileDisk file location of the VM
--file-sizeAllocated file size of the VM
--nonsparseThe command which allocates the entire disk
--graphicsSpecifies which tool would be used for GUI installation (e.g. vnc, spice)
--vcpuNumber of virtual CPUs that will be used
--ramAmount of RAM allocated
--cdromInstallation media
--networkNetwork used for the VM
--os-typeType of the operating system
--os-variantIf you are not sure about the OS variant, type “generic”
Translate »

Enjoy this blog? Please spread the word :)