Installing Linux Kernal-Based Virtual Machine (KVM) on CentOS 5.4 Server (Part I)

Taken from the KVM main site:

Linux Kernel-Based Virtual Machine (KVM) is a full virtualisation solution for Linux on x86 hardware containing virtualization extension (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. KVM also requires a modified QEMU although work is underway to get the required changes upstream. 

This guide is modified from the article from Howtoforge – “Virtualization With KVM On A CentOS 5.2 Server”  and IBM – Quick Start Guide for installing and running KVM. But we will be installing Virt-Manager on the CentOS. I hope to put in additional  note for us to consider as well. Similarly, the this write-up draw information from  

Step 1. Set SELINUX to “disabled”

# vim /etc/selinux/config

Step 2: Check that hardware support hardware virtualisation

# egrep '(vmx|svm)' --color=always /proc/cpuinfo

Your output should be something like this

flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush
dts acpi mmx fxsr sse sse2 ss ht tm syscall nx pdpe1gb rdtscp lm constant_tsc nonstop_tsc pni monitor
ds_cpl vmx smx est tm2 cx16 xtpr popcnt lahf_lm

If you do not get this output, then we can conclude that your hardware does not support virtualisation

Before you do a yum, make sure you  have EPEL Repository enabled. For more information see Red Hat Enterprise Linux / CentOS Linux Enable EPEL (Extra Packages for Enterprise Linux) Repository

Step 3: Install the KVM and virtinst (tools to create virtual machines)

yum install kvm kmod-kvm qemu libvirt python-virtinst

Reboot the System

# shutdown -r now

Step 4: Verify that the kernel has is loaded

# lsmod | grep kvm

the output should be something like

kvm_amd               50452  0
kvm                   109264  1 kvm_intel

Check that the KVM is installed

# virsh -c qemu:///system list
Id Name                 State

Step 5: Setting up of a Network Bridge so that the VM can be accessed from other hosts on the same network

a. Install the Bridge

# yum install bridge-utils

b. Configure the Bridge. Create the “bridge configuration file”. Ensure the BOOTPROTO, BROADCAST, IPADDR, NETMASK and NETWORK are the same as /etc/sysconfig/network-scripts

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

c. Modify the /etc/sysconfig/network-scripts/ifcfg-eth0. Amend as follows

# Chelsio Communications Inc T310 10GbE Single Port Adapter

d. Disable NetworkManager

# chkconfig NetworkManager off
# service NetworkManager stop
# chkconfig network on

e. Restart the Network

# service network start

f. Verify that the Network Bridge is working

# ifconfig
br0       Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::210:a7ff:fe05:afeb/64 Scope:Link
          RX packets:17 errors:0 dropped:0 overruns:0 frame:0
          TX packets:53 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1160 (1.1 KiB)  TX bytes:14875 (14.5 KiB)

eth0      Link encap:Ethernet  HWaddr yy:yy:yy:yy:yy:yy
          inet6 addr: fe80::210:a7ff:fe05:afeb/64 Scope:Link
          RX packets:13662 errors:7 dropped:160 overruns:4 frame:0
          TX packets:11646 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:15144608 (14.4 MiB)  TX bytes:1379942 (1.3 MiB)
          Interrupt:74 Base address:0xcc00

lo        Link encap:Local Loopback
          inet addr:  Mask:
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:38 errors:0 dropped:0 overruns:0 frame:0
          TX packets:38 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:4308 (4.2 KiB)  TX bytes:4308 (4.2 KiB)

virbr0    Link encap:Ethernet  HWaddr 00:00:00:00:00:00
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:35 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:9987 (9.7 KiB)

Step 6: Installing Virt-Manager on CentOS on a remote or local server

# yum install virt-manager
 Package           Arch     Version                             Repository
 virt-manager      x86_64   0.6.1-12.el5                        base      1.5 M
Installing for dependencies:
 e4fsprogs-libs    x86_64   1.41.9-3.el5                        base      104 k
                   x86_64   2.16.0-3.el5                        base       17 k
 gtk-vnc           x86_64   0.3.8-3.el5                         base       81 k
 gtk-vnc-python    x86_64   0.3.8-3.el5                         base       12 k
 libvirt           x86_64   0.6.3-33.el5_5.3                    updates   2.0 M
 libvirt-python    x86_64   0.6.3-33.el5_5.3                    updates   137 k
 python-virtinst   noarch   0.400.3-9.el5_5.1                   updates   380 k
 xen-libs          x86_64   3.0.3-105.el5_5.5                   updates   156 k
 xz-libs           x86_64   4.999.9-0.3.beta.20091007git.el5    base       95 k

Transaction Summary
Install      10 Package(s)
Upgrade       0 Package(s)

Total download size: 4.5 M
Is this ok [y/N]:

Step 7: Install Virtual Machines using virt-install

a. Do put an ISO of the Operating System into Server so that you can build the Virtual Machine From. If you only have the disk but not the ISO, you may want to look at “Making Disc Images using mkisofs” from Linux Toolkit

b. Do also take a look at the Guest Support Status from KVM to know what is supported for the version of KVM.

Installing Linux Kernal-Based Virtual Machine (KVM) on CentOS 5.4 Server (Part II)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s