Install KVM Hypervisor on CentOS 7.x and RHEL 7.x

KVM is an open source hardware virtualization software through which we can create and run multiple Linux based and windows based virtual machines simultaneously. KVM is known as Kernel based Virtual Machine because when we install KVM package then KVM module is loaded into the current kernel and turns our Linux machine into a hypervisor.

In this post first we will demonstrate how we can install KVM hypervisor on CentOS 7.x and RHEL 7.x and then we will try to install virtual machines.

Before proceeding KVM installation, let’s check whether your system’s CPU supports Hardware Virtualization.

Run the beneath command from the console.

[root@linuxtechi ~]# grep -E '(vmx|svm)' /proc/cpuinfo

We should get the word either vmx or svm in the output, otherwise CPU doesn’t support virtualization.

Step:1 Install KVM and its associate packages

Run the following yum command to install KVM and its associated packages.

[root@linuxtechi ~]# yum install qemu-kvm qemu-img virt-manager libvirt libvirt-python libvirt-client virt-install virt-viewer bridge-utils

Start and enable the libvirtd service

[root@linuxtechi ~]# systemctl start libvirtd
[root@linuxtechi ~]# systemctl enable libvirtd

Run the beneath command to check whether KVM module is loaded or not

[root@linuxtechi ~]# lsmod | grep kvm
kvm_intel             162153  0
kvm                   525409  1 kvm_intel
[root@linuxtechi ~]#

In Case you have Minimal CentOS 7 and RHEL 7 installation , then virt-manger will not start for that you need to install x-window package.

[root@linuxtechi ~]# yum install "@X Window System" xorg-x11-xauth xorg-x11-fonts-* xorg-x11-utils -y

Reboot the Server and then try to start virt manager.

Step:2 Start the Virt Manager

Virt Manager is a graphical tool through which we can install and manage virtual machines. To start the virt manager type the ‘virt-manager‘ command from the terminal.

[root@linuxtechi ~]# virt-manager


Step:3 Configure Bridge Interface

Before Start creating VMs , let’s first create the bridge interface. Bridge interface is required if you want to access virtual machines from outside of your hypervisor network.

[root@linuxtechi ~]# cd /etc/sysconfig/network-scripts/
[root@linuxtechi network-scripts]# cp ifcfg-eno49 ifcfg-br0
[root@linuxtechi network-scripts]#

In cp command replace the interface name that suits to your system and then edit the Interface file and set followings:

[root@linuxtechi network-scripts]# vi ifcfg-eno49

Edit the Bridge file (ifcfg-br0) and set the followings:

[root@linuxtechi network-scripts]# vi ifcfg-br0

Replace the IP address and DNS server details as per your setup.

Restart the network Manager Service to enable the bridge interface.

[root@linuxtechi ~]# systemctl restart NetworkManager
[root@linuxtechi ~]#

Note: By default, in CentOS 7 / RHEL 7 Network Manager service is enabled and if have made changes in network files then we must restart Network Manager service to make the changes into the effect. In Case network Manager service is disabled and stopped then we can use network service (systemctl restart network)

Check the Bridge interface using below command :

[root@linuxtechi ~]# ip addr show br0

Step:4 Start Creating Virtual Machines.

Now Create Virtual Machine either from the command line using ‘virt-install‘ command or from GUI (virt-manager )

Let’s Create a virtual machine of “Windows Server 2012 R2” using virt-manager.

Start the “virt-manager”

Go to the File Option, click on “New Virtual Machine”


We will be using ISO file as installation media. In the next step Specify the path of ISO file.


Click on Forward.

Specify the Compute Resources : RAM and CPU as per your setup.


Click on Forward to proceed further.

Specify the storage Size of Virtual Machine, In my case I am using 25G.


In the Next step Specify the Name of Virtual Machine and select network as ‘ Bridge bro’


Click on Finish to start the installation.


Follow the screen instructions and complete the installation.

Creating a virtual Machine from Command Line:

Virtual Machines can be created from the console as well using ‘virt-install’ command. In the following example i going to virtual machine of Ubuntu 16.04 LTS.

[root@linuxtechi ~]# virt-install --name=Ubuntu-16-04 --file=/var/lib/libvirt/images/ubuntu16-04.dsk --file-size=20 --nonsparse --graphics spice --vcpus=2 --ram=2048 --cdrom=ubuntu-16.04-server-amd64.iso --network bridge=br0 --os-type=linux --os-variant=generic
Starting install...
Allocating 'ubuntu16-04.dsk'               | 20 GB 00:00:00
Creating domain...


Follow the instruction now and complete the installation.

In the above ‘virt-install’ command we have used following options :

  • –name = <Name of the Virtual Machine>
  • –file = <Location where our virtual machine disk file will be stored >
  • –file-size = < Size of the Virtual Machine, in my case it is 20GB >
  • –nonsparse = < Allocate the whole storage while creating>
  • –graphics = < Specify the graphical tool for interactive installation, in above example I am using spice >
  • –vcpu = < Number of virtual CPU for the Machine >
  • –ram = < RAM size for the virtual Machine >
  • –cdrom = < Virtual CD ROM which specify the installation media like ISO file >
  • –network = < it is used to specify which network we will use for the virtual machine, in this example I am bridge interface>
  • –os-type = < Operating system type like linux and window>
  • –os-variant= <KVM maintains the OS variants like ‘fedora18′, ‘rhel6’ and ‘winxp’ , this option is optional and if you not sure about OS variant you can mentioned it as generic>

Once the Installation is completed we can access the Virtual Machine console from ‘virt-manager‘ as shown below.


That’s it, basic installation and configuration of KVM hypervisor is completed.

29 thoughts on “Install KVM Hypervisor on CentOS 7.x and RHEL 7.x”

  1. I don’t get X running when entering the command above. When I reboot I get a license prompt which I except but then it just fails to the shell

  2. Hello, I have RHEL 7.3 installed and can not attach a CD/DVD or boot from one. I keep getting: Driver ‘host:cdrom’ is not whitelisted.
    I have found that alot of People have this Problem, but never found a solution. Can anyone here help.

  3. Hi , it’s a very good introduction. But I don’t understand why it’s necessary to manually setup a bridge in step2.
    This bridge is used as a physical network interface. I still have to create a ‘virtual network bridge. eg. virbr1’ with or without this one, and attached to the physical interface.

  4. Hi, i follow the instruction you give in the tuto, but i have error when i launch my VM.
    g-invoke-error-quark: Could not locate spice_gtk_session_get: ‘spice_gtk_session_get’: /lib64/ undefined symbol: spice_gtk_session_get (1)
    After search on google, i saw this, but if i try to install gir1.2-spice-client-gtk-3.0, it tell me no packets available.
    I’m on Centos 7

  5. How about libguestfs-tools?

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

  6. Hi There

    Awesome guide. I just have a slight problem when I create the bridge adapter. I do everything as you have it but when I systmectl restart network i loose connectivity to my server. I cant even ping it afterwards. I have to go to the server and delete the bridge adapter and then reboot. Any suggestions?

    Kind Regards

  7. I was able to create everything per your instruction but I realized I can’t ssh into the host machine. Upon checking the ip address, the was no IP for the host adapter but IP for the bridge. Now the question is if I want to ssh into the host server what do I do. Thanks

  8. I’m doing something stupid, I know it. Everything works up to the last frame – “centos_01 login:” I have no login, how do I create a root user and/or a regular user?

  9. when running virt-manager, in case of : ImportError: No module named ‘requests.packages.urllib3’ , i did the following :
    pip uninstall requests
    pip uninstall urllib3
    yum remove python-urllib3
    yum remove python-requests

    and then reinstall virt-manager
    yum install virt-manager virt-install virt-viewer


Leave a Comment