CentOS 7/RHEL7: Install KVM (QEMU)

This post will guide you how to install and configure KVM or QEMU in CentOS 7 or RHEL 7 Linux Operating system. How do I create a KVM virtual machine on CentOS7 Linux. How to setup a virtualization host using KVM technology in Linux. How to create virtual machines using KVM in Linux.

What is KVM?


Kernel Virtual Machine KVM (for Kernel-based Virtual Machine) is a full virtualization solution for Linux on x86 hardware containing virtualization extensions (Intel VT or AMD-V). It 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. Using KVM, one can run multiple virtual machines running unmodified Linux or Windows images. Each virtual machine has private virtualized hardware: a network card, disk, graphics adapter, etc.

KVM Installation


Before installing kvm packages, you need to check whether your system’s CPU supports Hardware Virtualization technology. You need to make sure that your Intel or AMD CPU have developed extensions for their processors, deemed respectively Intel VT-x and AMD-V. Type the following command to check the compatibility:

# grep -E '(vmx|svm)' /proc/cpuinfo

If you get the vmx or svm word from the output, and it indicated that your CPU support virtualization.

#1 KVM Packages installation

You need to use the yum command to install kvm packages and its associate packages, type:

# yum install qemu-kvm qemu-img virt-manager libvirt libvirt-python libvirt-client virt-install virt-viewer bridge-utils

#2 Start Libvirtd service

You need to start the libvirtd service, type the following command:

# systemctl start libvirtd
# systemctl enable libvirtd

#3 check KVM Module if it is loaded

Type the following command to check if the KVM module is loaded or not:

# lsmod | grep kvm

Outputs:

root@osetc ~ # lsmod | grep kvm
kvm_intel 167936 124
kvm 643072 1 kvm_intel
irqbypass 16384 5 kvm

#4 configure bridge interface

You need to create a new bridge interface based on one network interface, such as: eth0.
Type the following command to update the eth0 configuration file:

#vi /etc/sysconfig/network-scripts/en0

Add the below line:

BRIDGE=br0

then you can create a new bridge file or copy ifcfg-eth0 to ifcfg-br0, type:

#cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-br0

or

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

add the below lines:

TYPE=Bridge
BOOTPROTO=static
DEVICE=br0
ONBOOT=yes
IPADDR=192.168.1.2
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=192.168.1.1

save and close the file. and restart the network service, type:

#systemctl restart network.service

#5 Start the Virt Manager

Type the following command to launch the virtual manager a graphical tool, so that you can create a new virtual machine to follow the guide.

# virt-manager

 

You might also like:

Sidebar



back to top