Setup Xen on CentOS5

From Bitbull Wiki
Jump to navigation Jump to search

1. install needed software

yum groupinstall Virtualization
yum install vsftpd

2. prepare kernel as needed

vi /boot/grub/grub.conf
default=0
timeout=5
title CentOS (2.6.18-92.1.10.el5xen)
        root (hd0,0)
        kernel /xen.gz-2.6.18-92.1.10.el5 dom0_mem=256M
        module /vmlinuz-2.6.18-92.1.10.el5xen ro root=/dev/vg0/root 
        module /initrd-2.6.18-92.1.10.el5xen.img

3. activate needed services

chkconfig xend on
chkconfig xendomains on
chkconfig vsftpd on

4. configure xen

vi /etc/xen/xend-config.sxp
(vnc-listen '192.168.0.0')
(vncpasswd 's0what')

5. reboot and create Xen Guest

lvcreate -nxen01 -L5G vg0
vi /etc/xen/xen01
import os, re
arch = os.uname()[4]
if re.search('64', arch):
    arch_libdir = 'lib64'
else:
    arch_libdir = 'lib'
kernel = "/usr/lib/xen/boot/hvmloader"
builder='hvm'
memory = 384
shadow_memory = 8
name = "xen01"
acpi=0
vif = [ 'type=ioemu, bridge=xenbr0' ]
#cdrom access is sometimes buggy 
#so do a loop mount of install image: mount -oloop deb.iso /mnt/deb/
disk = [ 'phy:/dev/VG0/xen01,ioemu:hda,w', 'phy:/dev/loop0,hdc:cdrom,r' ]
#disk = [ 'phy:/dev/VG0/xen01,ioemu:hda,w' ]
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'
device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'
boot="d" #cd=d hd=c, change it after setup
sdl=1
vnc=1
stdvga=0
serial='pty'
usb=1
usbdevice='mouse'

6. start virtual machine and connect to console

xm create /etc/xen/xen01
xm list

7. connect to console and setup

 vncviewer xen-dom0-host 5901 #get port from id of xm list
 

8.change boot order after setup

vi /etc/xen/xen01
boot="c"

8. if all is allright, move config file to autostart folder

mv /etc/xen/xen01 /etc/xen/auto/

that's it...
you can find more infos at: http://www.centos.org/docs/5/
the cool thing with lvm is, that you are able to take "live snap shots" by lvm on dom0
the problem is, they are really big

i wrote this nice script to back up all my unix hosts by rsync
it can does rotate generations and sub generations of the folders
feel free to use it: http://www.bitbull.ch/dl/scripts/backup-get-rsync.sh