Xen virtualization on CentOS linux

Xen virtualization on CentOS linux

Introduction ~

What is Virtualization? ~ virtualization is technique of  running multiple operating system (OS) on same physical hardware at same time.
There are three types of Virtualization technologies

1) Full virtualization –
a) Hardware emulation – KQEMU
b) Binary translation – VirtualBox
c) Classic virtualization – OpenVZ
2) Para-virtualization
3) OS-level virtualization – Linux-VServer and OpenVZ

** Xen is an open-source para-virtualizing virtual machine monitor (VMM), or “hypervisor”,for a variety of processor. Xen can securely execute multiple virtual machines on a single physical system with near native performance.

** Xen Prerequisites –

1) iproute2 package
2) Linux bridge-utils (/sbin/brctl)
3) Linux hotplug system (/sbin/hotplug and related scripts)

Step 1) How to install Xen on Centos ~

[root@arun ~]# yum install xen.i386 xen-devel.i386   xen-libs.i386 libvirt.i386  libvirt-devel.i386  libvirt-python.i386 virt-manager.i386 virt-clone.i386

Step 2) How to install Xen Kernel for Centos ~

[root@arun ~]# yum install kernel-xen.i686  kernel-xen-devel.i686

* Once installation is completed; Please check the CentOS boot loader configuration file ie “/boot/grub/grub.conf”… and make sure that the first boot entry should look like this…

title CentOS (2.6.18-164.15.1.el5xen)
root (hd0,4)
kernel /boot/xen.gz-2.6.18-164.15.1.el5
module /boot/vmlinuz-2.6.18-164.15.1.el5xen ro root=LABEL=/ rhgb quiet
module /boot/initrd-2.6.18-164.15.1.el5xen.img

Step 3) Reboot the system so that system will boot with Xen Kernel….

That’s it Xen infrastructure is installed on CentOS.

[[root@arun ~]# rpm -qa | egrep “xen|virt” | sort
kernel-xen-2.6.18-164.15.1.el5
kernel-xen-devel-2.6.18-164.15.1.el5
libvirt-0.6.3-20.1.el5_4
libvirt-devel-0.6.3-20.1.el5_4
libvirt-python-0.6.3-20.1.el5_4
python-virtinst-0.400.3-5.el5
virt-manager-0.6.1-8.el5
xen-3.0.3-94.el5_4.3
xen-devel-3.0.3-94.el5_4.3
xen-libs-3.0.3-94.el5_4.3
[[root@arun ~]#
Step 4 ) Test Xen setup – make sure that “libvirtd” service is running

Step 5) Install first Guest CentOS –

* Create Disk as file as shown below….

[[root@arun ~]# dd if=/dev/zero  of=/var/xen-disk/centOS.hdd bs=4k seek=2048k count=0
0+0 records in
0+0 records out
0 bytes (0 B) copied, 0.000191 seconds, 0.0 kB/s
[[root@arun ~]#  mke2fs -j /var/xen-disk/centOS.hdd
mke2fs 1.39 (29-May-2006)
/var/xen-disk/centOS.hdd is not a block special device.
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1048576 inodes, 2097152 blocks
104857 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2147483648
64 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[[root@arun ~]# mount -o loop /var/xen-disk/centOS.hdd  /mnt/
[[root@arun ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda5              55G   12G   41G  22% /
tmpfs                 829M   12K  829M   1% /dev/shm
/dev/sda2              23G   15G  7.8G  65% /mydata
none                  829M  104K  829M   1% /var/lib/xenstored
/var/xen-disk/centOS.hdd
7.9G  147M  7.4G   2% /mnt
[[root@arun ~]#

* We are going to install guestOS from CD/DVD image so we will export this image via FTP so let us
configure ftp server….

* We have copied Centos CD/DVD in “/home/CentOS5.0/” location….

[root@arun ~]# ls /home/CentOS5.0/
CentOS            RELEASE-NOTES-cz.html  RELEASE-NOTES-fr       RELEASE-NOTES-nl.html     repodata
EULA              RELEASE-NOTES-de       RELEASE-NOTES-fr.html  RELEASE-NOTES-pt          RPM-GPG-KEY-beta
GPL               RELEASE-NOTES-de.html  RELEASE-NOTES-it       RELEASE-NOTES-pt_BR       RPM-GPG-KEY-CentOS-5
images            RELEASE-NOTES-en       RELEASE-NOTES-it.html  RELEASE-NOTES-pt_BR.html  TRANS.TBL
isolinux          RELEASE-NOTES-en.html  RELEASE-NOTES-ja       RELEASE-NOTES-pt.html
NOTES             RELEASE-NOTES-es       RELEASE-NOTES-ja.html  RELEASE-NOTES-ru
RELEASE-NOTES-cz  RELEASE-NOTES-es.html  RELEASE-NOTES-nl       RELEASE-NOTES-ru.html
[root@arun ~]#

* I have changed anonymous FTP home from default one to “/home/CentOS5.0/” Please details below….

[root@arun ~]# grep ftp /etc/passwd
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
[root@arun ~]#  vi /etc/passwd
[root@arun ~]# grep ftp /etc/passwd
ftp:x:14:50:FTP User:/home/CentOS5.0:/sbin/nologin
[root@arun ~]#

* Now, restart FTP server and try to access to ftp with IPaddress assigned to bridge “virbr0”. In my case it is “ftp://192.168.122.1”

* Start installation now using “virt-install”

[root@arun ~]# virt-install –name arunOS –os-type=linux –ram=300 –file /var/xen-disk/centOS.hdd –location ftp://192.168.122.1 –nographics –bridge=virbr0

Starting install…

* Welcome to CentOS

+————–+ Manual TCP/IP Configuration +—————+
|                                                            |
| Enter the IPv4 and/or the IPv6 address and prefix          |
| (address / prefix).  For IPv4, the dotted-quad netmask     |
| or the CIDR-style prefix are acceptable. The gateway and   |
| name server fields must be valid IPv4 or IPv6 addresses.   |
|                                                            |
| IPv4 address: 192.168.122.2___ / 255.255.255.0___          |
| Gateway:      192.168.0.1______________________________    |
| Name Server:  _________________________________________    |
|                                                            |
|            +—-+                      +——+            |
|            | OK |                      | Back |            |
|            +—-+                      +——+            |
|                                                            |
|                                                            |
+————————————————————+

<Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

* Welcome to CentOS

+—————————–+ Warning +——————————+
|                                                                      |
| /dev/xvda currently has a loop partition layout.  To use this disk   |
| for the installation of CentOS, it must be re-initialized, causing   |
| the loss of ALL DATA on this drive.                                  |
|                                                                      |
| Would you like to format this drive?                                 |
|                                                                      |
|         +————–+                  +————–+           |
|         | Ignore drive |                  | Format drive |           |
|         +————–+                  +————–+           |
|                                                                      |
|                                                                      |
+———————————————————————-+

<Tab>/<Alt-Tab> between elements   |  <Space> selects   |  <F12> next screen

* Welcome to CentOS

+————————-+ Partitioning Type +————————-+
|                                                                       |
|    Installation requires partitioning of your hard drive.  The        |
|    default layout is reasonable for most users.  You can either       |
|    choose to use this or create your own.                             |
|                                                                       |
| Remove all partitions on selected drives and create default layout.   |
| Remove linux partitions on selected drives and create default layout. |
| Use free space on selected drives and create default layout.          |
| Create custom layout.                                                 |
|                                                                       |
|       Which drive(s) do you want to use for this installation?        |
|                              [*] xvda ^                               |
|                                       #                               |
|                                                                       |
|                          +—-+   +——+                            |
|                          | OK |   | Back |                            |
|                          +—-+   +——+                            |
|                                                                       |
|                                                                       |
+———————————————————————–+

<Space>,<+>,<-> selection   |   <F2> Add drive   |   <F12> next screen

* Welcome to CentOS

+—————————-+ Partitioning +—————————-+
|                                                                        |
|      Device        Start    End     Size       Type     Mount Point    |
| /dev/xvda                                                            ^ |
|   Free space            1    1045    8192M  Free space               # |
|                                                                      : |
|                                                                      : |
|                                                                      : |
|                                                                      : |
|                                                                      : |
|                                                                      : |
|                                                                      : |
|                                                                      v |
|                                                                        |
|    +—–+   +——+   +——–+   +——+   +—-+   +——+      |
|    | New |   | Edit |   | Delete |   | RAID |   | OK |   | Back |      |
|    +—–+   +——+   +——–+   +——+   +—-+   +——+      |
|                                                                        |
|                                                                        |
+————————————————————————+

F1-Help     F2-New      F3-Edit   F4-Delete    F5-Reset    F12-OK

* Welcome to CentOS

+—————————-+ Partitioning +—————————-+
|                                                                        |
|      Device        Start    End     Size       Type     Mount Point    |
| /dev/xvda                                                            ^ |
|   xvda1                 1     829    6502M  ext3        /            # |
|   xvda2               830     893     502M  swap                     : |
|   Free space          894    1044    1184M  Free space               : |
|                                                                      : |
|                                                                      : |
|                                                                      : |
|                                                                      : |
|                                                                      : |
|                                                                      v |
|                                                                        |
|    +—–+   +——+   +——–+   +——+   +—-+   +——+      |
|    | New |   | Edit |   | Delete |   | RAID |   | OK |   | Back |      |
|    +—–+   +——+   +——–+   +——+   +—-+   +——+      |
|                                                                        |
|                                                                        |
+————————————————————————+

F1-Help     F2-New      F3-Edit   F4-Delete    F5-Reset    F12-OK


* Same way configure TZ,root password,packages,boot loader options etc…

* Welcome to CentOS

+———————+ Formatting +———————-+
|                                                         |
| Formatting / file system…                             |
|                                                         |
|                           70%                           |
|                                                         |
+———————————————————+

<Tab>/<Alt-Tab> between elements   |  <Space> selects   |  <F12> next screen

That’s it!

Thank you,
Arun Bagul

Similar Posts:

Leave a Reply

Your email address will not be published.