High Performance XEN On Ubuntu 8.04

This tutorial provides step-by-step instructions on how to install XEN on a Ubuntu 8.04 Server System amd64 without compromising on the disk I / O and network bandwidth. You can find all software used in the Ubuntu repositories, so no external files or source of compilation are needed.

Xen is an open-source para-virtualization virtual machine monitor (WWW), or "hypervisor", for the x86 processor architecture. Xen can run safely several VMs on a single physical system with near-Native Performance. Xen allows corporate quality functions, including:

- Virtual Machines with performance relatives of equipment.
- Live migration management VMs between physical hosts.
- Up to 32 virtual processors by guest virtual machine, with VCPU hotplug.
- x86/32, x86/32 with EAP, and x86/64 platform support.
- The virtualization technology Intel (VT-x) for unmodified guest operating systems (Microsoft Windows).
- The virtualization technology AMD (aka Pacifica SVM) on strengthening AM2 and F Opterons (2006H2)
- Excellent support equipment (supports almost all Linux device drivers).

1. Partition And Primary OS Installation

I will use Ubuntu Hardy Heron (x86_64) for the two host OS (dom0) and customers operating systems (Domu). Before that, you must have a ready target system partitions as in the following example:

For example, we have 120 gigabytes of disk space and we want to use 2 guest operating systems on:
- Take as the minimum required for host operating system (dom0), say 10-12GB => to create the first partition accordingly.
- We will divide the rest of the free space in 2 partitions, each for 2 guest OS (Domu) => to create the next two partitions accordingly.
Install Ubuntu Hardy Heron (x86_64) Server Edition (http://www.ubuntu.com/products/whatisubuntu/serveredition) on the first score. Then, on this we will install Xen things and use what OS host (dom0). As a best practice, dom0 should not be used for any purpose in production, except for the control guest OS. While select "ssh" in the selection of packages during the OS installation.

After the OS installation the first job is to update/upgrade the OS. Login to the system as root and type following commands:

# apt-get update

# apt-get upgrade


2. Host OS And Xen Installation
To install Xen and all needed dependencies, all we have to do is run the following command:

# apt-get install ubuntu-xen-server

The ubuntu-xen-server package installs the Ubuntu kernel 2.6.24-17-xen and other dependent xen packages.

Also upgrade the vi editor as follows:

# apt-get install vim

We also need to add the loop module to the kernel every time we boot our system, so we edit /etc/modules. If you already have a loop line in there, make it look like this, otherwise add it at the bottom of the file:

# vi /etc/modules

loop max_loop=64
That's all. Now reboot the system. And after the reboot check the OS and xen service as follows:

# uname -a

# xm list


3 Creating Filesystem For Guest OS (domU)
For the creation of domU we will be using "debootstrap". Here we will be using direct physical disk partitions and no filesystem images for better disk I/O for the guest OS. So format the partition for your filesystem choice. If you are interested in the xfs filesystem then you must install the "xfsprogs" package on dom0 like this:

# apt-get install xfsprogs
class
To create a filesystem on the second partition we use the following command:

If you are choosing ext3 then:

# mkfs.ext3 /dev/sda2

If you are choosing xfs then:

# mkfs.xfs /dev/sda2

Post creation of filesystem in target partition mount it to /mnt:

# mount /dev/sda2 /mnt


4. Installing The Guest OS
Install the base OS stuff in /mnt using "debootstrap":

# debootstrap --arch amd64 hardy /mnt http://archive.ubuntu.com/ubuntu

This is going to take sometime depending on your Internet connection speed.

Once done, prepare the chroot environment for /mnt:

# mount --bind /dev /mnt/dev

# mount proc /mnt/proc -t proc

# chroot /mnt /bin/bash

Open another terminal and copy a couple of files from dom0 to /mnt's respective folder:

# cp /etc/resolv.conf /mnt/etc/resolv.conf

# cp /etc/network/interface /mnt/network/interface

# cp /etc/apt/source.list /mnt/etc/apt/sources.list

# cp -R /lib/modules/2.6.24-17-xen/* /mnt/lib/modules/2.6.24-17-xen/

(If the respective folder is not present, then please create it before copying.)

Now again from the domU chroot environment use the following commands:

# apt-get update

# apt-get upgrade

# apt-get install vim ssh

If you are using the xfs filesystem then also install xfsprogs as follows:

# apt-get install xfsprogs

Update /etc/fstab as follows:
If you are using the ext3 filesystem then:

/dev/hda1 / ext3 defaults 1 2
If you are using the xfs filesystem then:

/dev/hda1 / xfs defaults 1 2
This is the minimal setup of the domU environment. Not set the root password as:

# passwd


It's going to prompt you for root's password, so provide some secret for it.

Now exit from the chroot environment:

# exit

Now umount all partitions:

# umount /mnt/dev /mnt/proc /mnt


5. Creation Of Xen Config File
Now create the first guest OS's xen config file named domu1.cfg in the /etc/xen/ folder like this:

vi /etc/xen/domu1.cfg

kernel = '/boot/vmlinuz-2.6.24-17-xen'
ramdisk = '/boot/initrd.img-2.6.24-17-xen'
memory = '512'
#
# Disk device(s).
#
root = '/dev/hda1 ro'
disk = [
'phy:/dev/sda2,hda1,w',
]
#
# Hostname
#
name = 'domu1'
#
# Networking
#
vif = [ 'ip=192.168.1.102,mac=00:16:3E:62:DA:BB' ]
#
# Behaviour
#
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
vcpus = '2'
extra = 'xencons=tty1'

You must use a free and different IP for each guest OS.

Then start the first domU like this:

# xm create /etc/xen/domu1.cfg -c

Log in using root and that's all... your first guest OS (domu1) is ready now.

In dom0, to list running OS's, type:

# xm list

The steps to create /dev/sda3 for the second domU are similar...

The same steps can be followed for i386 also...

DiggIt!Add to del.icio.usAdd to Technorati Faves

0 comments: