diff --git a/elements/vm/finalise.d/51-grub b/elements/vm/finalise.d/51-grub index 4ee5517e9..b1ca7b16f 100755 --- a/elements/vm/finalise.d/51-grub +++ b/elements/vm/finalise.d/51-grub @@ -22,11 +22,12 @@ fi [ -n "$IMAGE_BLOCK_DEVICE" ] PART_DEV=$IMAGE_BLOCK_DEVICE BOOT_DEV=$(echo $IMAGE_BLOCK_DEVICE | sed -e 's/p1//') -GRUB_OPTS=${GRUB_OPTS:---modules="biosdisk part_msdos"} -if [ $DIB_RELEASE != 'precise' ]; then - GRUB_OPTS="$GRUB_OPTS --target=i386-pc" -fi -$GRUBNAME "$GRUB_OPTS" $BOOT_DEV +GRUB_OPTS=${GRUB_OPTS:""} +# XXX: This is buggy: +# - --target=i386-pc is invalid for non-i386/amd64 architectures +# - and for UEFI too. +# GRUB_OPTS="$GRUB_OPTS --target=i386-pc" +$GRUBNAME --modules="biosdisk part_msdos" $GRUB_OPTS $BOOT_DEV # This might be better factored out into a per-distro 'install-bootblock' # helper. if [ -f "/boot/grub/grub.cfg" ] ; then @@ -34,7 +35,16 @@ if [ -f "/boot/grub/grub.cfg" ] ; then elif [ -f "/boot/grub2/grub.cfg" ] ; then GRUB_CFG=/boot/grub2/grub.cfg fi +RELEASE=`lsb_release -cs` +[ -n "$RELEASE" ] # grub-mkconfig generates a config with the device in it, +# This shouldn't be needed, but old code has bugs +if [ $RELEASE = 'precise' ] ; then + # Replace the search attempt with a hardcoded root as the Ubuntu reference + # images use. + sed -i "s%search --no.*%%" $GRUB_CFG + sed -i "s%set root=.*%set root=(hd0,1)%" $GRUB_CFG +fi # force use of a LABEL: # NOTE: Updating the grub config by hand once deployed should work, its just # prepping it in a different environment that needs fiddling.