From 37aaf354c93a73fe3495cf0292cb37c80f4adf08 Mon Sep 17 00:00:00 2001 From: robertmh Date: Thu, 26 Jun 2008 07:03:26 +0000 Subject: [PATCH] 2008-06-26 Robert Millan * util/grub.d/10_linux.in: Avoid passing UUIDs to Linux when either "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" does not exist, or when a Linux image includes no initrd. --- ChangeLog | 6 ++++++ util/grub.d/10_linux.in | 30 +++++++++++++++++------------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7f288a1bb..d5aa52455 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-06-26 Robert Millan + + * util/grub.d/10_linux.in: Avoid passing UUIDs to Linux when either + "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" does not exist, or when a + Linux image includes no initrd. + 2008-06-21 Javier Martín * util/i386/pc/grub-setup.c (setup): Remove literal "core.img" in a diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index 6ee705ba0..2512bd26e 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -27,17 +27,17 @@ else OS="${GRUB_DISTRIBUTOR} GNU/Linux" fi -if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] ; then - # loop-AES arranges things so that /dev/loop/X can be our root device, but - # the initrds that Linux uses don't like that. - case ${GRUB_DEVICE} in - /dev/loop/*|/dev/loop[0-9]) - LINUX_ROOT_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"` - ;; - *) - LINUX_ROOT_DEVICE=${GRUB_DEVICE} - ;; - esac +# loop-AES arranges things so that /dev/loop/X can be our root device, but +# the initrds that Linux uses don't like that. +case ${GRUB_DEVICE} in + /dev/loop/*|/dev/loop[0-9]) + GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"` + ;; +esac + +if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ + || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" ; then + LINUX_ROOT_DEVICE=${GRUB_DEVICE} else LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} fi @@ -109,6 +109,7 @@ while [ "x$list" != "x" ] ; do rel_dirname=`make_system_path_relative_to_its_root $dirname` version=`echo $basename | sed -e "s,^[^0-9]*-,,g"` alt_version=`echo $version | sed -e "s,\.old$,,g"` + linux_root_device_thisversion="${LINUX_ROOT_DEVICE}" initrd= for i in "initrd.img-${version}" "initrd-${version}.img" \ @@ -120,11 +121,14 @@ while [ "x$list" != "x" ] ; do done if test -n "${initrd}" ; then echo "Found initrd image: ${dirname}/${initrd}" >&2 + else + # "UUID=" magic is parsed by initrds. Since there's no initrd, it can't work here. + linux_root_device_thisversion=${GRUB_DEVICE} fi cat << EOF menuentry "${OS}, linux ${version}" { - linux ${rel_dirname}/${basename} root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} + linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} EOF if test -n "${initrd}" ; then cat << EOF @@ -137,7 +141,7 @@ EOF cat << EOF menuentry "${OS}, linux ${version} (single-user mode)" { - linux ${rel_dirname}/${basename} root=${LINUX_ROOT_DEVICE} ro single ${GRUB_CMDLINE_LINUX} + linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro single ${GRUB_CMDLINE_LINUX} EOF if test -n "${initrd}" ; then cat << EOF