Bug#671734: grub-common: Add a variable in /etc/default/grub to pass specific kernel parameters in the 'recovery mode' entry

bilibop project quidame at poivron.org
Sun May 6 14:13:41 UTC 2012


Package: grub-common
Version: 1.99-21
Severity: normal
Tags: upstream

Hello,

When running Debian in 'recovery mode' from GRUB2, there in fact is no
'recovery' or 'failsafe' useful option added to the kernel parameters: only
'single'. I think it would be nice to add a variable in /etc/default/grub for
that. For example (keeping 'single' as implicit parameter):

GRUB_CMDLINE_LINUX_RECOVERY="noapic noapm nodma nomce nolapic nomodeset nosmp"

For me, the best reason to do that is that it is easier to delete useless
options in the GRUB-edit mode than remember the names of relevant options in
the same mode.
Because I'm not familiar with the patch mechanism, I can't provide you a clean
patch, but I can show you a possible way:

1. Modification in Upstream util/grub-mkconfig.in: add line #240:
   GRUB_CMDLINE_LINUX_RECOVERY \

2. Modification in Upstream util/grub.d/10_linux.in: replace line #195:
        "single ${GRUB_CMDLINE_LINUX}"
    by:
        "single ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_RECOVERY}"

3. Modification in Debian debian/default/grub.diff: add line #12:
+GRUB_CMDLINE_LINUX_RECOVERY="noapic noapm nodma nomce nolapic nomodeset nosmp"

NOTE: here the parameters listed in GRUB_CMDLINE_LINUX_RECOVERY are the sames
than those used in the 'failsafe' entry of Debian LiveCDs.
If you think I have to contact directly upstream maintainers, or if you prefer
I send you relevant patches, feel free to say me; I'm open and I will try.

Thanks



-- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'testing-proposed-updates')
Architecture: i386 (i686)

Kernel: Linux 3.2.0-2-486
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages grub-common depends on:
ii  gettext-base        0.18.1.1-5
ii  libc6               2.13-30
ii  libdevmapper1.02.1  2:1.02.67-2
ii  libfreetype6        2.4.9-1
ii  libfuse2            2.8.7-2
ii  zlib1g              1:1.2.6.dfsg-2

Versions of packages grub-common recommends:
pn  os-prober  <none>

Versions of packages grub-common suggests:
ii  desktop-base   6.0.7
ii  grub-emu       <none>
ii  multiboot-doc  <none>
ii  xorriso        1.2.2-1

-- Configuration Files:
/etc/grub.d/10_linux changed:
set -e
prefix="/usr"
exec_prefix="${prefix}"
datarootdir="${prefix}/share"
.. "${datarootdir}/grub/grub-mkconfig_lib"
export TEXTDOMAIN=grub
export TEXTDOMAINDIR="${datarootdir}/locale"
CLASS="--class gnu-linux --class gnu --class os"
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
  OS=GNU/Linux
else
  OS="${GRUB_DISTRIBUTOR} GNU/Linux"
  CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) ${CLASS}"
fi
case ${GRUB_DEVICE} in
  /dev/loop/*|/dev/loop[0-9])
    GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
    # We can't cope with devices loop-mounted from files here.
    case ${GRUB_DEVICE} in
      /dev/*) ;;
      *) exit 0 ;;
    esac
  ;;
esac
if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
    || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
    || uses_abstraction "${GRUB_DEVICE}" lvm; then
  LINUX_ROOT_DEVICE=${GRUB_DEVICE}
else
  LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
fi
if [ "x`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2>/dev/null || true`" = xbtrfs ] \
    || [ "x`stat -f --printf=%T /`" = xbtrfs ]; then
  rootsubvol="`make_system_path_relative_to_its_root /`"
  rootsubvol="${rootsubvol#/}"
  if [ "x${rootsubvol}" != x ]; then
    GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
  fi
fi
linux_entry ()
{
  os="$1"
  version="$2"
  recovery="$3"
  args="$4"
  if ${recovery} ; then
    title="$(gettext_quoted "%s, with Linux %s (recovery mode)")"
  else
    title="$(gettext_quoted "%s, with Linux %s")"
  fi
  printf "menuentry '${title}' ${CLASS} {\n" "${os}" "${version}"
  if ! ${recovery} ; then
      save_default_entry | sed -e "s/^/\t/"
  fi
  # Use ELILO's generic "efifb" when it's known to be available.
  # FIXME: We need an interface to select vesafb in case efifb can't be used.
  if [ "x$GRUB_GFXPAYLOAD_LINUX" != x ]; then
      if [ "x$GRUB_GFXPAYLOAD_LINUX" != xtext ]; then
	  cat << EOF
	load_video
EOF
      fi
	  cat << EOF
	set gfxpayload=$GRUB_GFXPAYLOAD_LINUX
EOF
  fi
  cat << EOF
	insmod gzio
EOF
  if [ x$dirname = x/ ]; then
    if [ -z "${prepare_root_cache}" ]; then
      prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/")"
    fi
    printf '%s\n' "${prepare_root_cache}"
  else
    if [ -z "${prepare_boot_cache}" ]; then
      prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
    fi
    printf '%s\n' "${prepare_boot_cache}"
  fi
  message="$(gettext_printf "Loading Linux %s ..." ${version})"
  cat << EOF
	echo	'$message'
	linux	${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
EOF
  if test -n "${initrd}" ; then
    message="$(gettext_printf "Loading initial ramdisk ...")"
    cat << EOF
	echo	'$message'
	initrd	${rel_dirname}/${initrd}
EOF
  fi
  cat << EOF
}
EOF
}
case x`uname -m` in
    xi?86 | xx86_64)
	list=`for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do
                  if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
              done` ;;
    *)
	list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do
                  if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
	     done` ;;
esac
prepare_boot_cache=
prepare_root_cache=
while [ "x$list" != "x" ] ; do
  linux=`version_find_latest $list`
  echo "Found linux image: $linux" >&2
  basename=`basename $linux`
  dirname=`dirname $linux`
  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" \
	   "initrd-${version}" "initramfs-${version}.img" \
	   "initrd.img-${alt_version}" "initrd-${alt_version}.img" \
	   "initrd-${alt_version}" "initramfs-${alt_version}.img" \
	   "initramfs-genkernel-${version}" \
	   "initramfs-genkernel-${alt_version}"; do
    if test -e "${dirname}/${i}" ; then
      initrd="$i"
      break
    fi
  done
  config=
  for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
    if test -e "${i}" ; then
      config="${i}"
      break
    fi
  done
  initramfs=
  if test -n "${config}" ; then
      initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"`
  fi
  if test -n "${initrd}" ; then
    echo "Found initrd image: ${dirname}/${initrd}" >&2
  elif test -z "${initramfs}" ; then
    # "UUID=" magic is parsed by initrd or initramfs.  Since there's
    # no initrd or builtin initramfs, it can't work here.
    linux_root_device_thisversion=${GRUB_DEVICE}
  fi
  linux_entry "${OS}" "${version}" false \
      "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
  if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
    linux_entry "${OS}" "${version}" true \
	"single ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_RECOVERY}"
	#"single ${GRUB_CMDLINE_LINUX}"
  fi
  list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
done


-- no debconf information





More information about the Pkg-grub-devel mailing list