XCP on USB: automate initrd rebuild

XCP, the Xen Cloud Platform, is meant to be installed on a regular hard drive. Some folks install on a USB flash drive instead, but the initrd does not include USB support, and will not boot.

A good article to solve this problem for those installing XCP manually is here. Thanks to GoofyGeek on spiceworks.com for the write-up.

For those automating installs with an answer file, here is a quick recipe to automate the solution.

1. The post-install-script

The following script should be run after the root filesystem has been completely installed, but before it has been unmounted. It rebuilds the initrd file with the USB drivers. It also removes the splash screen that covers up informative boot messages and adds a helpful boot message.

#!/bin/bash -x

ROOT=$1

# rebuild initrd with USB drivers
KVERS=`cd $ROOT/lib/modules; echo *xen`
mv $ROOT/boot/initrd-$KVERS.img $ROOT/boot/initrd-$KVERS.img-
chroot $ROOT mkinitrd -v --with-usb --without-multipath /boot/initrd-$KVERS.img $KVERS

# remove annoying splash screen and print a meaningful boot message
chroot $ROOT sed -i.orig -e '/^ *append/s/ \(quiet\|splash\) / /g' -e '/^timeout/ a \
DISPLAY /boot/intro.txt' boot/extlinux.conf
cat > $ROOT/boot/intro.txt
<<EOF
Booting from USB

type 'xe' to boot normally, or just wait
type 'fallback' to boot a failsafe kernel

EOF

2. Adding the script to the installation

Add the script to the installation by inserting a <script> element into the answer file. For more information, again refer here.

Make the script available on a web server, probably in the same place the answer file is kept. Then add the <script> element to the answer file:

<installation>
[...]
  <script stage="filesystem-populated" type="url">
    http://kickstart-server.example.com/xen-post-script.sh
  </script>
</installation>

The install should now automatically build a new initrd with USB drivers, and the XCP install should come up after the first reboot.

If you have trouble, pull the USB drive and mount it somewhere else. In the support.tar.bz2 tarball, check the install-log file, which has a complete transcript of the install.

In the likely event that these instructions contain mistakes, please submit a comment below. Thanks for reading!

Leave a comment

Your comment