How to install and configure Xen® Virtualization in Linux/Centos/Redhat – Command Line Step by Step

ADVERTISEMENT

I think every body knows What is Xen®?. Now i am directly going to the topic of the installation and configuring the Xen Virtualization in Centos. CentOS is a free operating system based on Red Hat Enterprise Linux (RHEL). It exists to provide a free enterprise class computing platform and strives to maintain 100% binary compatibility with its upstream distribution.

 

ADVERTISEMENT
Article will continue after the ad

 

 

So no worry about getting the CentOS for the installation.

Requirements:

  1. Xen 3.0 rpm for Installation.
  2. Xen – Kernel for booting
  3. Virt-Manager for Managing the Xen Virtualization
  4. Virt-Viewer for getting the console of the Guest opertating system.

This guide only for the person that who didn’t installed the Xen and Xen – Kernel during installation of CentOS. If you have installed the CentOS with Xen already, you scan skip to Step 5.

PS: Here i am showing the fully virtualized platform. I used Win XP as Guest Operating System.

Step 1: First need to check, in which kernel you have logged or booted.

[root@node01 ~]# uname -r
2.6.18-238.el5

Step 2: From the above you can find that the system not booted with Xen kernel, check whether Xen and Xen – kernel installed on the CentOS or not.

[root@node01 ~]# rpm -qa | grep kernel ———-> For Checking Xen – Kernel Installed
kernel – 2.6.18-238.el5

[root@node01 ~]# rpm -qa | grep xen ———–> For Checking Xen installed

Step 3: From the above, confirmed that the Xen and Xen – kernel haven’t installed on the machine, So you can install it using the following command, i used the YUM Repo for installing RPM’s. Include the Virt-Manager and Virt-Viewer also.

[root@node01 ~]# yum install xen virt-manager virt-viewer
centos | 1.3 kB 00:00
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package xen.x86_64 0:3.0.3-120.el5 set to be updated
–> Processing Dependency: xen-hypervisor-abi = 3.1 for package: xen
–> Processing Dependency: libxenstore.so.3.0()(64bit) for package: xen
–> Running transaction check
—> Package kernel-xen.x86_64 0:2.6.18-238.el5 set to be installed
—> Package python-virtinst.noarch 0:0.400.3-11.el5 set to be updated
–> Processing Dependency: libvirt-python >= 0.2.1 for package: python-virtinst
—> Package xen-libs.x86_64 0:3.0.3-120.el5 set to be updated
–> Running transaction check
—> Package libvirt-python.x86_64 0:0.8.2-15.el5 set to be updated
–> Processing Dependency: libvirt = 0.8.2-15.el5 for package: libvirt-python
–> Processing Dependency: libvirt.so.0(LIBVIRT_0.8.0)(64bit) for package: libvirt-python
–> Processing Dependency: libvirt.so.0()(64bit) for package: libvirt-python
–> Running transaction check
—> Package libvirt.x86_64 0:0.8.2-15.el5 set to be updated
—> Package virt-manager.x86_64 0:0.6.1-13.el5 set to be updated
—> Package virt-viewer.x86_64 0:0.0.2-3.el5 set to be updated
–> Finished Dependency ResolutionDependencies Resolved===============================================================
Package Arch Version Repository Size
===============================================================
Installing:
xen x86_64 3.0.3-120.el5 centos 1.9 M
Installing for dependencies:
kernel-xen x86_64 2.6.18-238.el5 centos 20 M
libvirt x86_64 0.8.2-15.el5 centos 3.2 M
libvirt-python x86_64 0.8.2-15.el5 centos 235 k
python-virtinst noarch 0.400.3-11.el5 centos 380 k
xen-libs x86_64 3.0.3-120.el5 centos 163 k
virt-manager x86_64 0.6.1-13.el5 centos 1.6 M
virt-viewer x86_64 0.0.2-3.el5 centos 25 k
Transaction Summary
===============================================================
Install 6 Package(s)
Upgrade 0 Package(s)Total download size: 26 M
Is this ok [y/N]: y
Downloading Packages:
(1/8): libvirt-python-0.8.2-15.el5.x86_64.rpm | 235 kB 00:00
(2/8): python-virtinst-0.400.3-11.el5.noarch.rpm | 380 kB 00:00
(3/8): xen-3.0.3-120.el5.x86_64.rpm | 1.9 MB 00:00
(4/8): kernel-xen-2.6.18-238.el5.x86_64.rpm | 20 MB 00:00
(5/8): libvirt-0.8.2-15.el5.x86_64.rpm | 3.2 MB 00:00
(6/8): xen-libs-3.0.3-120.el5.x86_64.rpm | 163 kB 00:00
(7/8): virt-manager-0.6.1-13.el5.x86_64.rpm | 1.6 MB 00:00
(8/8): virt-viewer-0.0.2-3.el5.x86_64.rpm | 25 kB 00:00
——————————————————————————–
Total 15 MB/s | 27.7 MB 00:01
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
1/8 Installing : xen-libs
2/8 Installing : libvirt
3/8 Installing : libvirt-python
4/8 Installing : python-virtinst
5/8 Installing : kernel-xen
6/8 Installing : xen
7/8 Installing : virt-viewer
8/8 Installing : virt-manager Installed:
xen.x86_64 0:3.0.3-120.el5 virt-manager.x86_64 0:0.6.1-13.el5 virt-viewer.x86_64 0:0.0.2-3.el5 Dependency Installed:
kernel-xen.x86_64 0:2.6.18-238.el5 libvirt.x86_64 0:0.8.2-15.el5
libvirt-python.x86_64 0:0.8.2-15.el5 python-virtinst.noarch 0:0.400.3-11.el5
xen-libs.x86_64 0:3.0.3-120.el5 Complete!

Step 4: Once the Xen and Xen – Kernel installed, Make the changes in the /etc/grub.conf to boot the Xen – Kernel by default. Other wise You have to select the Menu from Splash screen during booting. So edit /etc/grub.conf.

The following one is before editing the /etc/grub.conf. You can look at the default field = 1, it means by default it will boot from the second kernel ie Normal El5 Kernel. Numbers starts from 0,1 and so on.

[root@node01 ~]# vi /etc/grub.conf
#boot=/dev/sda
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-238.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-238.el5
module /vmlinuz-2.6.18-238.el5xen ro root=LABEL=/ rhgb quiet
module /initrd-2.6.18-238.el5xen.img
title CentOS (2.6.18-238.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-238.el5 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.18-238.el5.img

After edit the /etc/grub.conf, Default field changed to 0 for booting Xen – kernel by default.

[root@node01 ~]# vi /etc/grub.conf
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-238.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-238.el5
module /vmlinuz-2.6.18-238.el5xen ro root=LABEL=/ rhgb quiet
module /initrd-2.6.18-238.el5xen.img
title CentOS (2.6.18-238.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-238.el5 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.18-238.el5.img

Step 5: Reboot the Server, As from the above the server should boot with Xen – Kernel. Check it using the following command.

[root@node01 ~]# uname -r
2.6.18-238.el5xen

Step 6: Create the directory for storing the virtual machine data. like below.

[root@node01 ~]# mkdir /vm

Step 7: Next is to create the Virtual Machine in command line mode. virt-install command will be used for creating the Virtual Machines.  It has two modes of creation.

  1. Interactive Mode
  2. Non – Interactive Mode.

Interactive Mode:

in this mode the command you will have to put –prompt at the end. When you give a command, it will prompt you to asking the specification of the virtual machine that you want to create. The following was the sample command for creating  fully virtualized  Windows XP guest os with RAM of 256MB, HDD of 2GB using the Disk image file of /vm/winxp.dmg and will start the installation of os from CD ROM drive /dev/hdc.  At the end of execution of the command, the virtual machine viewer will starts automatically for providing the console of the guest operating system.This mode will be very easy to create the VM.

[root@node01 ~]# virt-install –prompt

Would you like a fully virtualized guest (yes or no)? This will allow you to run unmodified operating systems. yes
What is the name of your virtual machine? WinXP
How much RAM should be allocated (in megabytes)? 256
What would you like to use as the disk (file path)? /vm/winxp.img
How large would you like the disk (/vm/winxp.img) to be (in gigabytes)? 2
What is the install CD-ROM/ISO or URL? /dev/hdc

Starting install…
Creating storage file…                                 | 2.0 GB     00:00
Creating domain…                                       |    0 B     00:03     



Non – Interactive Mode:

In this mode you have enter options manually, it will not prompt you for anything. The following command will create the new VM as identical as interactive mode. in the end of execution of command, virtual machine will start to begin to install win xp.

[root@node01 ~]# virt-install -n WinXP -r 256 -f /vm/winxp.img -s 2 -v –os-type windows –os-variant winxp -c /dev/hdc

Starting install…
Creating storage file…                                 | 2.0 GB     00:00
Creating domain…                                       |    0 B     00:01
Domain installation still in progress. Waiting for installation to complete.


The above are the command for installing the Guest OS on the Xen. For managing the Xen you can use the virt-manager.

ADVERTISEMENT

POSTS YOU MAY LIKE -:)

Share This Post

Shares