CentOS domU under Debian

I finally got a CentOS 5 domU running under Debian.
The xen-tools xen-create-image method didn’t work. I managed to find an appropriate build script for centos5, but it was pretty badly out of date, trying to install RPM versions that don’t exist on the mirror servers any more. Trying to bring it back up to date would have been a PITA. It has the RPM versions hard-coded in the script.
However the instructions at http://wiki.kartbuilding.net/index.php/Create_Centos5_DomU_on_Debian_Etch_Dom0 worked a treat.
After following those steps, I converted it from a file-based image, to an LVM, with the following steps:
Manually create logical volumes for the filesystem and swap. I use 40G filesystem LVs and 128M swaps.

# mkdir /mnt/loop
# mkdir /mnt/cenots
# mount /home/andrew/centos.5-0.img /mnt/loop -o loop
# mount /dev/mapper/ember-centos5–disk /mnt/centos
# cd /mnt/loop
# cp -Rp bin boot dev etc home lib media mnt opt root sbin selinux srv sys tmp usr var ../centos
# cd
# umount /mnt/loop
# umount /mnt/centos

Then edit /etc/xen/domains/centos.cfg and change the following lines:

kernel = “/boot/vmlinuz-2.6.18-4-xen-686”
ramdisk = “/boot/initrd.img-2.6.18-4-xen-686”
vif = [‘bridge=xenbr0’]
disk = [‘file:/xens/name_of_new_server_to_be/centos.5-0.img,sda1,w’,’file:/xens/name_of_new_server_to_be/centos.swap,sda2,w’]

To:

kernel = ‘/boot/vmlinuz-2.6.18-6-xen-686’
ramdisk = “/boot/initrd.img-2.6.18-6-xen-686”
vif = [ ‘ip=192.168.1.13’ ]
disk = [ ‘phy:ember/centos5-disk,sda1,w’, ‘phy:ember/centos5-swap,sda2,w’ ]

Then “xm create centos”. Boom! Centos 5, running as a domU on a Debian Etch dom0, from a logical volume.
And I still have the original centos5 image file for creating fresh domUs.