Following are the steps I took to install Lucid on Xen using Steve Kemp's fantastic xen-tools package. I did some cursory research and couldn't find any Lucid templates, so I modified the existing templates. It's not very elegant, but it appears to have gotten the job done (many VMs running for days now without problems).
UPDATE: The dev version of xen-tools, and presumably debootstrap, has lucid/pygrub support, so pretty soon these instructions will be redundant (i.e., you might take a look at those versions as well/instead).
System:
- dom0 running Debian Lenny with kernel 2.6.26-2-xen-amd64 and Xen 3.2 (community, of course)
- domU Ubuntu 10.04 LTS
- Copy files from edgy.d template (latest available) to lucid.d.
Code:cp -r /usr/lib/xen-tools/edgy.d /usr/lib/xen-tools/lucid.d- Link debootstrap gutsy profile (latest available) to lucid.
Code:ln -s /usr/share/debootstrap/scripts/gutsy /usr/share/debootstrap/scripts/lucid- Link current xen directory (many tools expect to find it here).
Code:ln -s /usr/lib/xen-3.2-1 /usr/lib/xen- Link pygrub to /usr/bin (many tools expect to find it here).
Code:ln -s /usr/lib/xen/bin/pygrub /usr/bin/pygrub- Modify /etc/xen-tools/xm.tmpl so that it lists root device first (pygrub requires this to work properly); replace the entire section following "# Disk device(s)." and preceding "# Hostname" with:
Code:{ for ( my $i = 0; $i <= $#PARTITIONS; $i++ ) { if ( $PARTITIONS[$i]{'mountpoint'} eq '/' ) { $OUT .= "root = '/dev/$device" . ($i + 1) . " ro'\n"; } } $OUT .= "disk = [\n"; for ( my $i = 0; $i <= $#PARTITIONS; $i++ ) { if ( $PARTITIONS[$i]{'mountpoint'} eq '/' ) { $OUT .= " '$PARTITIONS[$i]{'imagetype'}$PARTITIONS[$i]{'image'},$device" . ( $i + 1 ) .",w',\n"; } } for ( my $i = 0; $i <= $#PARTITIONS; $i++ ) { if ( $PARTITIONS[$i]{'mountpoint'} ne '/' ) { $OUT .= " '$PARTITIONS[$i]{'imagetype'}$PARTITIONS[$i]{'image'},$device" . ( $i + 1 ) .",w',\n"; } } $OUT .= " ]\n"; }- Replace the entire contents of /usr/lib/xen-tools/lucid.d/30-disable-gettys with the following (to work with non-event.d, non-inittab, hvc0 setup):
Code:#!/bin/sh # # This script comments out all virtual terminals which aren't on the # first console - that must remain so that 'xm console ...' works # correctly. # # Steve # -- # http://www.steve.org.uk/ # # Updated for Lucid; DDS/ABC # prefix=$1 # # Source our common functions # if [ -e /usr/lib/xen-tools/common.sh ]; then . /usr/lib/xen-tools/common.sh else . ./hooks/common.sh fi # # Log our start # logMessage Script $0 starting # # Remove the links for upstart # rm ${prefix}/etc/init/tty[!1].conf # # Are we using an alternative serial device? # if [ ! -z "${serial_device}" ]; then serial_device=`basename ${serial_device}` # Let the user know. logMessage "Replacing default serial device (tty1) with ${serial_device}; having destroyed the rest" # replace existing device. mv ${prefix}/etc/init/tty1.conf ${prefix}/etc/init/${serial_device}.conf sed -i -e s/tty1/${serial_device}/ ${prefix}/etc/init/${serial_device}.conf # make sure that it is allowed to login. echo $serial_device >> ${prefix}/etc/securetty fi # # Log our finish # logMessage Script $0 finished- Create /etc/xen-tools/role.d/pygrub, and set its executable bit, with the following contents, to allow booting from the guest kernel, which is what I prefer (if you prefer to boot from dom0-supplied kernels, you can skip this); the script is based on Wejn's tremendously helpful pygrub script, which I modified to install a newer kernel version and the linux-virtual package; note that you'll need to use this role and the pygrub role:
Code:#!/bin/sh # # Configure the new image to be suitable for booting via pygrub # # Wejn # -- # http://wejn.org/ # # Updated for Lucid; DDS/ABC # prefix=$1 # # Source our common functions - this will let us install a Debian package. # if [ -e /usr/lib/xen-tools/common.sh ]; then . /usr/lib/xen-tools/common.sh else echo "Installation problem" fi # # Update APT lists. # chroot ${prefix} /usr/bin/apt-get update # # Install the packages # set -e installDebianPackage ${prefix} perl installDebianPackage ${prefix} libklibc installDebianPackage ${prefix} klibc-utils installDebianPackage ${prefix} initramfs-tools #installDebianPackage ${prefix} linux-image-2.6-xen-amd64 installDebianPackage ${prefix} linux-virtual # Force initrd if none exists echo ${prefix}/boot/initrd* | grep -q 2\\.6 if [ $? -ne 0 ]; then chroot ${prefix} update-initramfs -c -k `ls -1 ${prefix}/lib/modules/ | head -n 1` fi # Generate grub menu.lst LNZ=`basename \`ls -1 ${prefix}/boot/vmlinuz*|tail -n 1\`` RD=`basename \`ls -1 ${prefix}/boot/initrd*|tail -n 1\`` mkdir -p ${prefix}/boot/grub cat - <<-EOF > ${prefix}/boot/grub/menu.lst default 0 timeout 5 title Debian/Ubuntu root (hd0,0) kernel /boot/$LNZ root=/dev/xvda2 ro initrd /boot/$RD EOF
Be sure to edit your /etc/xen-tools/xen-tools.conf as appropriate (e.g., changing the distribution to lucid) and use --role=udev,pygrub when you run xen-create-image; also, comment out the kernel and initrd lines so xm defaults to pygrb; finally, you may also want to add the line "serial_console = hvc0" (no quotes) so that Xen provides the correct console based on the 30-disable-gettys script, above. (A diff between my working xen-tools.conf and the package version is at post #3, below). Note that this will create a VM with a root user (and password that you set if you enabled that option in xen-tools.conf). I've written a few roles to secure the installation, including disabling the root password, which I'll try to post if I have some time.
I can produce diffs, if there's interest in the above. Please jump in and modify the above, add to it, etc. As I said, it's not a very elegant solution, but I needed it quickly. (I also must apologize in advance if I'm not able to keep up with questions here, if there are any--we're a bit slammed with work at the moment.)
Bookmarks