Wednesday 30 May 2012

Virtulization in Linux



                                 KVM Installation and configuration

What is the difference between KVM and Xen?


Xen is an external hypervisor; it assumes control of the machine and divides resources among guests. On the other hand, KVM is part of Linux and uses the regular Linux scheduler and memory management. This means that KVM is much smaller and simpler to use; it is also more featureful; for example KVM can swap guests to disk in order to free RAM.

KVM only run on processors that supports x86 hvm (vt/svm instructions set) whereas Xen also allows running modified operating systems on non-hvm x86 processors using a technique called paravirtualization. KVM does not support paravirtualization for CPU but may support paravirtualization for device drivers to improve I/O performance.

System requirements:

Minimum system requirements:

• 6GB free disk space (6GB plus the required disk space recommended by the guest operating system per guest. For most operating systems more than 6GB of disk space is recommended. )
• 2GB of RAM. (2GB of RAM plus additional RAM virtualized guests.)

Xen para-virtualization requirements:
Para-virtualized guests require a Red Hat Enterprise Linux 5 installation tree available over the network using the NFS, FTP or HTTP protocols.

Xen full virtualization requirements:

Full virtualization with the Xen Hypervisor requires:
• an Intel processor with the Intel VT extensions,
• an AMD processor with the AMD-V extensions, or
• an Intel Itanium processor.

KVM requirements:

The KVM hypervisor requires:
• an Intel processor with the Intel VT and the Intel 64 extensions, or
• an AMD processor with the AMD-V and the AMD64 extensions.

Installation of XEN and KVM installation in RHELx 64 bit.

First create the yum server

root@manish.bhandari#] vim /etc/yum.repo/yum.repo
 [server]

 name=yum server

baseurl=file:///mnt/Server
gpgcheck=0

[VT]
name=VT
baseurl=file:///mnt/VT
gpgcheck=0
:wq!


Now check the virtualization flag

root@manish.bhandari#] egrep '(vmx|svm)' --color=always /proc/cpuinfo
or
root@manish.bhandari#] grep -E 'svm|vmx' /proc/cpuinfo

XEN virtualization required packages are:

XEN : The xen package contains the hypervisor and basic virtualization tools.

Kernel-xen : The kernel-xen package contains a modified Linux kernel which runs as a virtual machine guest on the hypervisor.
Python-virtinst : Provides the virt-install command for creating virtual machines.
libvirt : libvirt is an API library for interacting with hypervisors. libvirt uses the xm virtualization framework and the virsh command line tool to manage and control virtual machines.

libvirt-python : The libvirt-python package contains a module that permits applications written in the Python programming language to use the interface supplied by the libvirt API.
virt-manager : virt-manager, also known as Virtual Machine Manager, provides a graphical tool for administering virtual machines. It uses libvirt library as the management API.

root@manish.bhandari#] yum install xen kernel-xen virt-manager libvirt libvirt-python python-virtinst virt-manager

KVM virtualization required packages are:

KVM : The kvm package contains the KVM kernel module providing the KVM
hypervisor on the default Red Hat Enterprise Linux kernel.

root@manish.bhandari#] yum install virt-manager kvm* libvirt libvirt-python python-virtinst qemu*

Then start the libvirtd service :

root@manish.bhandari#] /etc/init.d/libvirtd start

To check if KVM has successfully been installed, run

root@manish.bhandari#] virsh -c qemu:///system list

It should display something like this:
Id Name
State
----------------------------------

To configure the bridge create a file br0

root@manish.bhandari#] vim /etc/sysconfig/network-scripts/ifcfg-br0

DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
GATEWAY=192.168.4.1
IPADDR=192.168.4.12       (bash machine IP)
NETMASK=255.255.255.0
ONBOOT=yes
Modify /etc/sysconfig/network-scripts/ifcfg-eth0 as follow

root@manish.bhandri#] vim /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
#BOOTPROTO=none
#DNS1=145.253.2.75
#GATEWAY=192.168.0.1
HWADDR=00:1e:90:f3:f0:02
#IPADDR=192.168.4.12
#NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet
IPV6INIT=no
USERCTL=no
BRIDGE=br0

Then restart the system
root@manish.bhandari#] init 6

Now run the following command to start virtual machine.

root@manish.bhandari#] virt-manager

Then install virtual machine as your requirement :

                                                                                                                    Thanks &  Regards
                                                                                                                     Manish Bhandari