How to install KVM on CentOS 7 / RHEL 7 Server? Print

  • 0

Kernel-based Virtual Machine (KVM) is virtualization software for CentOS or RHEL 7. KVM turn your server into a hypervisor. Let's see how to setup and manage a virtualized environment with KVM in CentOS 7 or RHEL 7. 


Run the following command to test if CPU Support Intel VT and AMD-V Virtualization tech:

$ lscpu | grep Virtualization
Virtualization: VT-x

 

Follow installation steps of KVM on CentOS 7/RHEL 7 headless server

Step 1: Install KVM

Type the following yum command:

# yum install qemu-kvm libvirt libvirt-python libguestfs-tools virt-install



Start the libvirtd service:



# systemctl enable libvirtd
# systemctl start libvirtd


Step 2: Verify KVM installation


Make sure KVM module loaded using lsmod command and grep command:

 

# lsmod | grep -i kvm


Step 3: Configure bridged networking

 

This guide shows you how to manage the Network Bridge for KVM in Virtualizor.
Virtualizor will create a viifbr0 bridge.
viifbr0 assumes eth0 as the Network Device and detects the IP, Netmask, GATEWAY from :

/etc/sysconfig/network-scripts/ifcfg-eth0

In the event you have a network device (network interface) other thatn eth0, e.g. eth1, then you can configure Virtualizor to use eth1 as the Network interface to create the bridge.

Making the bridge permanent

You can make the bridge a permanent one so that whenever the OS is started, it will start with the bridge as soon as the network is created.
This guide presumes the network interface is eth0 and OS is CentOS.

Backup ifcfg-eth0

The contents of /etc/sysconfig/network-scripts/ifcfg-eth0 will look something like the following :

root# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 
BOOTPROTO=static 
TYPE=Ethernet 
HWADDR=00:25:90:98:35:90 
IPADDR=10.0.0.93 
NETMASK=255.255.255.0 
GATEWAY=10.0.0.1 
IPV6INIT=yes 
IPV6ADDR=2607:f0d0:1002:0011:0000:0000:0000:0002
IPV6_DEFAULTGW=2607:f0d0:1002:0011:0000:0000:0000:0001
ONBOOT=yes 

Make a copy of it :

root# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.bak 

Create the Bridge File

root# vi /etc/sysconfig/network-scripts/ifcfg-viifbr0

You will need to copy some parts of ifcfg-eth0 to ifcfg-viifbr0 :

DEVICE=viifbr0 
TYPE=Bridge 
BOOTPROTO=static 
IPADDR=10.0.0.93 
NETMASK=255.255.255.0 
GATEWAY=10.0.0.1 
ONBOOT=yes 
IPV6INIT=yes 
IPV6ADDR=2607:f0d0:1002:0011:0000:0000:0000:0002
IPV6_DEFAULTGW=2607:f0d0:1002:0011:0000:0000:0000:0001

Now save the file.

Edit the ifcfg-eth0 File

root# vi /etc/sysconfig/network-scripts/ifcfg-eth0 

It should look like the following :

DEVICE=eth0
HWADDR=00:25:90:98:35:90 
IPV6INIT=yes 
ONBOOT=yes 
BRIDGE=viifbr0 

Make sure to add correct HWADDR you can use ifconfig -a to find the mac address.
If nott using ipv6 then change it to IPV6INIT=no

Restart Network

We are almost setup now. Just make sure everything is correct before you restart the network. After that restart the network :

root# service network restart 


Was this answer helpful?

« Back