CentOS Xen

Installer ISO as Domain Guest

Installing any OS as a Xen guest booting an ISO can be a bit of a pain. There's a couple of steps involved, but it is possible, and it doesn't require munging or rebuilding ISOs.

Normally, when a Xen guest boots up, it will either use a GRUB emulator (pygrub, pvgrub, pvgrub2) or a kernel and initrd on the Xen domain filesystem directly. Since the ISO is booting using ISOLINUX, that means there needs to be an alternate option.

Here, we extract the kernel and initrd from the ISO, and use those to start the Xen guest, and then continue going through the ISO install as normal.

First, mount the ISO:

mkdir /tmp/centos-iso-contents
mount -o mount,ro centos.iso /tmp/centos-iso-contents

Get the kernel files needed:

cp /tmp/centos-iso-contents/isolinux/initrd.img /etc/xen/kernels/centos.initrd.img
cp /tmp/centos-iso-contents/isolinux/vmlinuz /etc/xen/kernels/centos.vmlinuz

You won't need anything else from the ISO, so you can unmount it if desired:

umount /tmp/centos-iso-contents

Create a Xen config file for the new guest. Located here in /etc/xen/configs. Here are the important settings, for booting the ISO for the first time:

kernel = "/etc/xen/kernels/centos-6.6/vmlinuz"
ramdisk = "/etc/xen/kernels/centos-6.6/initrd.img"
disk = [ 'file:/etc/xen/isos/centos.iso,hdc:cdrom,r' ]
boot = 'c'

Those are the bare basics. It doesn't include an entry for a place to install the OS. So, this assumes you understand Xen enough to know you need an additional disk. Here would be an example where you have a partition set apart for the install, with /dev/sda4 as the original device, and displaying it as /dev/xvda to the Xen guest:

disk = [ 'file:/tmp/boot.iso,hdc:cdrom,r','phy:/dev/sda4,xvda,rw' ]

That right there is enough to add into your Xen guest config file to get you booted into your ISO. Once you're finished, remove the kernel, ramdisk, boot entries, and the ISO from the disk entry in your Xen config file.

Then boot as normal:

bootloader = "pygrub"

That's it!

Using a Kickstarter File

You can use a kickstarter file if you'd like. In the simplest case, you'd normally rebuild an ISO with the ks.cfg file in the / directory on the filesystem. That won't work here because we're booting from a kernel outside of that filesystem. You can still tell Xen to use the ks.cfg file though, by passing it as a string to the kernel boot parameters:

extra = "ks=cdrom:/ks.cfg"