X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-autoinstaller.git/blobdiff_plain/be692f1eb06d2cd719dc301c82378e45d8bf358f..HEAD:/common/usr/lib/xen-tools/debian.d/93-setup-grub diff --git a/common/usr/lib/xen-tools/debian.d/93-setup-grub b/common/usr/lib/xen-tools/debian.d/93-setup-grub index 26fbdda..d3ba6fd 100755 --- a/common/usr/lib/xen-tools/debian.d/93-setup-grub +++ b/common/usr/lib/xen-tools/debian.d/93-setup-grub @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # This script sets up the ParaVM to use pygrub # @@ -63,14 +63,36 @@ done # if [ "$(chroot ${prefix} lsb_release -is)" = "Ubuntu" ] && \ dpkg --compare-versions "$(chroot ${prefix} lsb_release -rs)" ge 8.10; then - sed -i -e 's/xvc0/hvc0/' /etc/event.d/tty1 - sed -i -e 's/console=ttyS0[^ ]*/console=hvc0/' /boot/grub/menu.lst + sed -i -e 's/xvc0/hvc0/' ${prefix}/etc/event.d/tty1 + sed -i -e 's/console=ttyS0[^ ]*/console=hvc0/' ${prefix}/boot/grub/menu.lst fi # -# Regenerate automagic kernels list +# Since pv_ops kernels force block device names to xvda, xvdb, etc, +# the default root value of root=/dev/hda won't actually help us. # -chroot ${prefix} /usr/sbin/update-grub -y +# To work around that, find a UUID for the swap and root partitions +# and use that in the grub config (and also in /etc/fstab) +# +ROOT_DEV="$(perl -e 'print $ENV{"image-dev"}')" +SWAP_DEV="$(perl -e 'print $ENV{"swap-dev"}')" +ROOT_UUID="$(vol_id --uuid "$ROOT_DEV")" +SWAP_UUID="$(vol_id --uuid "$SWAP_DEV")" +for i in $(seq 1 "$NUMPARTITIONS"); do + var="PARTITION${i}" + case "$(echo ${!var} | cut -f1 -d:)" in + disk) ROOT_GUEST="$(echo ${!var} | cut -f8 -d:)";; + swap) SWAP_GUEST="$(echo ${!var} | cut -f8 -d:)";; + esac +done +sed -i -re "s%^(# *kopt=.*root=)[^ ]*%\1UUID=$ROOT_UUID%" ${prefix}/boot/grub/menu.lst +sed -i -e "s%${ROOT_GUEST}%UUID=${ROOT_UUID}%" ${prefix}/etc/fstab +sed -i -e "s%${SWAP_GUEST}%UUID=${SWAP_UUID}%" ${prefix}/etc/fstab + +# +# Regenerate automagic kernels list, saving our changes +# +chroot ${prefix} env UCF_FORCE_CONFFOLD=1 /usr/sbin/update-grub -y # # Log our finish