Skip to content

Centos5 domU on Debian Etch Dom0

2008 April 16
tags: ,
by Philippe Delodder

To get Centos 5 installed as
a guest on xen with Debian was pretty hardy not a lot of information in
the web and most of the things involved xen-tools and rinse which
didn’t work that perfect if it comes to handle rpm-based distro’s.

A few bits and pieces I brought to get tho give you this howto and
also a bit of memory support for me ;) . The howto will use and image
and lvm based system.

Download the image file

You can download the image file from http://www.jailtime.org/download:centos:v5.1 .After the download is complete, extract and mount the image to a tmp folder:

tar -xvfj centos5-1.date.tar.bz2
mkdir /mnt/image
mount -o loop centos5-1.img /mnt/image

Create Partition using LVM2

The creation of the lvm partition is fairly simple, if you have lvm
up and running you need only to create two logical volumes. If you
don’t have lvm and you wish to use it I would suggest read up this: http://howtoforge.com/linux_lvm or do these steps:

pvcreate /dev/sda1
vgcreate server /dev/sda1

One swap and one normal usage disk is created. I’ve chosen to name
the lvm partitions with the hostname of the domU and there purpose. The
disk will be 8G and the swap will take 512M. Replace <hostname>
with the hostname you wanted to be.

lvcreate -L 8G -n <hostname>-disk server
lvcreate -L 512M -n <hostname>-swap server

Format both partitions:

mkfs.ext3 /dev/server/<hostname>-disk
mkswap /dev/server/<hostname>-swap

Mount the <hostname>-disk to a temp dir:

mkdir /mnt/<hostname>
mount /dev/server/<hostname>-disk /mnt/<hostname>

Copy centos image to mounted lvm partition

To copy the image to the lvm partition will be used rsync. I guess
there could be made use of cp. But I used rsync since I read it on one
of the sources down below.

rysnc -av /mnt/image /mnt/xerv
umount /mnt/image

Modify the domU config file

Copy the config file from the image to the xen config directory:

cp centos5-1.cfg /etc/xen/<hostname>.cfg

Edit the newly copied config file accordingly to your basic
configuration, I decide to chose for a static IP, but you can uncomment
dhcp if you want to use dhcp. For a static IP you can eather this: vif
= [ 'bridge=xenbr0,mac=aa:00:00:00:00:11' ] or vif = [
'ip=10.0.0.1,mac=aa:00:00:00:00:11' ]. Here I use 10.0.0.1 as ip, for
the rest of this howto I’ll use the same static IP.

vim xerv.cfg

kernel = “/boot/vmlinuz-2.6.18-6-xen-vserver-686″
ramdisk = “/boot/initrd.img-2.6.18-6-xen-vserver-686″
memory = 256
name = “<hostname>”
vif = [ 'bridge=xenbr0,mac=aa:00:00:00:00:11' ]
#dhcp = “dhcp”
disk = ['phy:/dev/server/xerv-disk,sda1,w', 'phy:/dev/server/xerv-swap,sda2,w']
root = “/dev/sda1 ro”

Modify the CentOS guest (domU) for system and network service

Change your directory where you copied all the files:

cd /mnt/<hostname>

Change these setting to enable working:

vim etc/sysconfig/network

NETWORKING=yes
HOSTNAME=<hostname>

Change your net configuration accordingly:

vim etc/sysconfig/network-scripts/ifcfg-eth0

TYPE=Ethernet
DEVICE=eth0
BOOTPROTO=static
IPADDR=10.0.0.1
BROADCAST=10.0.0.255
NETMASK=255.255.255.0
NETWORK=10.0.0.0
GATEWAY=10.0.0.3
ONBOOT=yes

Add the ip and hostname to the hosts file:

vim etc/hosts

10.0.0.25 xerv.lan.delodder.be xerv

Finish off with umount the lvm partition:

umount /mnt/xerv

Run the domU guest

Now your ready to start the newly created domU Centos guest:

xm create -c /etc/xen/xerv.cfg

note: root default password is “password”…

Sources

http://www.conshell.net/wiki/index.php/Centos-4_on_Xen
http://www.pendragon.org/mywiki/Xen
http://www-128.ibm.com/developerworks/linux/library/l-xen/

No comments yet

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS

Bad Behavior has blocked 203 access attempts in the last 7 days.