Saturday, June 6, 2009

Debian installer on Xen post-install

Here are a few things that I like to do to a Xen domU that's been installed by the Debian lenny installer:

# for foo in hooks scripts/init-premount; do 
bar=/usr/share/initramfs-tools;
mkdir -p $bar/disabled/$foo;
dpkg-divert --divert $bar/disabled/$foo/thermal --rename $bar/$foo/thermal;
done
# update-initramfs -tu
# update-rc.d -f hwclock.sh remove
# update-rc.d -f hwclockfirst.sh remove
#


The first couple of 'lines' disable the loading of thermal modules from the initial RAM disk. The last two lines disable reading from and wiring to the hardware clock (as it doesn't exist in the domU).

The following lines are mostly for me. I like to have 'xvda1' and 'xvda2' mapped to separate logical volumes on the dom0 and this makes Debian's grub implementation grumpy. It's worth doing, so that you can resize these logical volumes without messing with the partition table that would otherwise have been created on 'xvda'.

# sed -i /grub/d /etc/kernel-img.conf
# perl -pi -e 's#/boot(/[^-]+)-\S+(\s|$)#$1$2#' /boot/grub/menu.lst
#


The first line stops the Debian kernel packages' post installation scripts from running 'update-grub', which fails when no '/dev/xvda' exists. This does, however, mean that the grub menu will not be updated when a new kernel is installed. The second line mitigates this by updating the menu file to use the links in '/', rather than the specific paths to the files in '/boot/'. This should allow pygrub to boot new kernels as they are installed, even though the grub menu will not be updated.