Matt-J.co.uk : Ramblings

Life, Tech and intravenous caffeine.

xVM Centos5.1 domU on solaris dom0


Runs with xenblk loaded
Originally uploaded by TrX07

Following on from my last post, I finally got the centos 5.1 install running as a guest VM under solaris xVM.

The problem (as expected in the last post), was the initrd-xen ramdisk that was created when I installed the centos kernel-xen package did not have the xennet or xenblk kernel modules needed to run as a xen guest.

However, installing the kernel-xen package HAD installed the needed arch and version specific modules, just had not put them into the xen initrd (I think centos5.1 expects to be run as a dom0).

So, once chrooted into your centos5.1 filesystem, and after installing the kernel-xen package (yum install kernel-xen)

Unpack the initrd image:
gzip -cd < /boot/initrd-2.6.18-53.1.4.el5xen-img | cpio -iv
(would suggest running this in an empty folder, as it makes including the right files when rebuilding the initrd easier]

Next, find the modules needed in the centos filesystem:
find /lib/ | grep xenblk
/lib/modules/2.6.18-53.1.4.el5xen/kernel/drivers/xen/blkfront/xenblk.ko

find /lib/ | grep xennet
/lib/modules/2.6.18-53.1.4.el5xen/kernel/drivers/xen/netfront/xennet.ko

Then add these to the unpacked initrd (under lib dir):
cp /lib/modules/rest_of_path/xennet.ko \
/wherever/extracted/initrd/is/lib/.
cp /lib/modules/rest_of_path/xenblk.ko \
/wherever/extracted/initrd/is/lib/.

Finally, we need to tell the init script of the initrd to load the modules at boot, and re-pack the initrd.
(Im using vi as my editor, you could use nano, emacs etc)

vi /path_to_your_extracted_initrd/init

add 'insmod /lib/xenblk.ko'
and 'insmod /lib/xennet.ko'

before all the other ‘insmod’ lines, and save

Now re-pack your initrd:
cd /path_to_extracted_initrd
find . | cpio -c -o -v | gzip -9 -n > ../newinitrd-xen.img

This will have placed a file called newinitrd-xen.img, one folder back up your directory tree. Now make your xVM / Xen config file point to this .img file for the ‘ramdisk=’ option… and boot!

voila! away it goes!
(as you can see from the image, it does not crap out anymore at the ’switchroot’ stage, and you can see further up my xennet and xenblk modules being loaded)

Anyway, that’s all for now, hope someone finds this useful!
–Matt

4 Comments so far

  1. James Legg February 27th, 2008 2:55 pm
  2. matt February 28th, 2008 7:36 pm

    Thanks James! I kindof worked this out, but with a slight variation to the theme (I meant to blog about it (In a pile of other things) but just have not got round to it.)

    For those who do not have a fast web connection, if you point your apache root at the base DIR of your centos DVD/CD/Loopback Image.

    Then do a virt-install as normal specifying the CD as the install source. When the CD boot’s and asks you where you want to install from (if you choose CD here it will bomb out, that is what the fuss is all about for people that are not following :P)..
    Choose HTTP/FTP, and enter Http://ip-of-Dom0/
    It will find the Centos webbized CD and install perfectly :)

    However with a 20Meg Connection, your version is better ;P
    //Matt

  3. James Legg February 29th, 2008 7:18 am

    It can work of nfs mounts as well so no need for apache if you loopback mount the iso - though of course you do need a distro that comes with xen aware kernels out of the box - which so far seems to rule out debian/ubuntu. And as you pointed out - I’m confusing domU and dom0 again!

  4. matt March 3rd, 2008 2:50 pm

    I have a Xen compiled DomU kernel + initrd for ubuntu 7.10 if you want it. I have packaged the kernel up into a .DEB.

    It does of course mean that you can’t apply later kernel updates without a manual recompile (or loose xen support) But if you would find it useful let me know!

    //Matt

Leave a reply

Mexico