Re: No more GRUB legacy at install time since wheezy?
On 27/06/11 17:59, Andrei POPESCU wrote:
> On Vi, 24 iun 11, 15:11:13, Freeman wrote:
>>
>> My menu.lst of Grub 0.97 included numerous different rc levels to select
>> from. Just a way of selecting between different interfaces while booting.
>>
>> So the following blocks in the automagic section of menu.lst resulted in a 4
>> item menu for each kernel, one item booting into GDM, the next starting
>> xinit with Openbox--booting from rc5.d, rc4.d rc3.d and rc2.d respectively.
>>
>> ## altoption boot targets option
>> ## multiple altoptions lines are allowed
>> ## e.g. altoptions=(extra menu suffix) extra boot options
>> ## altoptions=(single-user) single
>> # altoptions=(GDM) 5 vga=791 quiet
>> # altoptions=(Openbox) 4 vga=791 quiet
>> # altoptions=(Screen) 3 vga=791
>> # altoptions=(single-user mode) single
>
> That's a neat feature of grub1 that was not replicated (yet?) in grub2.
> Any shell script gurus here who might be interested in writing a patch?
> :)
>
> Regards,
> Andrei
I was in a hurry - this is the wrong way to do this, but it works, and
it should be relatively simple to implement this the correct way.
I just copied /etc/grub.d/10_linux to /etc/grub.d/11_linux, modified
11_linux and ran upgrade-grub(2). Seems to work OK, but it's a nasty hack.
My preference would be to create new custom variables in:-
/usr/sbin/grub-mkconfig and then call and populate them in:-
/etc/default/grub after modifying 10_linux to use them (sic).
NOTE 1: use chmod -x to stop files in /etc/grub.d from being acted on by
update-grub *regardless* or name or extension.
NOTE 2: I *like* grub2! /etc/default/grub is simple by design, you can
make it as complex as you like.
/etc/default/grub======================================================
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
GRUB_CMDLINE_LINUX="nouveau.modeset=0"
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
# Uncomment to disable graphical terminal (grub-pc only)
# NOTE: this will remove the splash screen
#GRUB_TERMINAL=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to
Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_LINUX_RECOVERY="true"
# Uncomment to get an annoying beep at grub start
#GRUB_INIT_TUNE="480 440 1"
# Uncomment to get an annoying tune at grub start
#GRUN_INIT="480 900 2 1000 2 800 2 400 2 600 3"
# for more of the same see info "grub --index-search play"
# Run grep "export GRUB_DEVICE" -A42 /usr/sbin/grub-mkconfig
# to see all the built-in grub variables
**********************************************************************
/etc/grub.d/11_linux===================================================
#! /bin/sh
set -e
# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
prefix=/usr
exec_prefix=${prefix}
bindir=${exec_prefix}/bin
libdir=${exec_prefix}/lib
. ${libdir}/grub/grub-mkconfig_lib
export TEXTDOMAIN=grub
export TEXTDOMAINDIR=${prefix}/share/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
# 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}" \
|| uses_abstraction "${GRUB_DEVICE}" lvm; then
LINUX_ROOT_DEVICE=${GRUB_DEVICE}
else
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
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 (GDM)")"
fi
printf "menuentry '${title}' ${CLASS} {\n" "${os}" "${version}"
save_default_entry | sed -e "s/^/\t/"
# 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
cat << EOF
set gfxpayload=$GRUB_GFXPAYLOAD_LINUX
EOF
fi
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}"
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
}
list=`for i in /boot/vmlinu[zx]-* /vmlinu[zx]-* ; do
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
done`
prepare_boot_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"; do
if test -e "${dirname}/${i}" ; then
initrd="$i"
break
fi
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
linux_entry "${OS}" "${version}" false \
"${GRUB_CMDLINE_LINUX} 5 vga=791 quiet"
list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
done
**********************************************************************
Just do a diff to see where I've made changes.
Refs: /etc/grub.d/README
info grub
Cheers
--
"I can't watch TV longer than five minutes without praying for nuclear
holocaust."
~ Bill Hicks
Reply to: