Brian Potkin wrote: > I have installed Debian a number of times to a USB stick with today's > daily image from > > http://cdimage.debian.org/cdimage/daily-builds/sid_d-i/current/i386/iso-cd/ > > An install was done with either no network connection or with the kernel > parameter 'recommends=false'. /etc/grub.d/30_otheros is created with a > typical 'search' line like so: > > search --no-floppy --fs-uuid --set cb83bfa2-57b7-4312-abb1-b0fc2fb7588a > > GRUB was installed either to the MBR of the stick or the MBR of /dev/sda. > In both cases, choosing to boot an OS on /dev/sda produces > > error: no argument specified. > Press any key to continue. > > Waiting for 10 seconds or pressing a key allows the boot to proceed. > > There is no error message when --set is altered to --set=root in the > line above. --set=root is already in the 'search' line for the OS on the > USB stick and used when os-prober is installed and run from it with > update-grub. Would it not be consistent to have it also in 30_otheros?
grub-installer's use of os-prober seems overly complicated. If grub uses os-prober itself, why does grub-installer redundantly use os-prober to generate a grub configuration? The answer seems to be that, in normal operations with recommends enabled and grub-pc installed, grub-installer does that, but then throws the configuration away, since it sees os-prober is installed and relies on grub-pc having used it. In the edge cases where grub-legacy is used, the configuration is used, as grub-legacy (apparently) does not use os-prober. AFAICS, the grub configuration generated by otheros.sh is entirely grub-legacy syntax. If it ever worked with grub-pc it was due to luck or compatability hacks in grub-pc. So I suspect my patch fixes this bug, and that modifying otheros to use --set=root is unnecessary, and would break it when used with grub-legacy. Which brings me to the attached, untested patch, which forces os-prober to be installed along with grub-pc even when recommends are disabled, and never uses otheros.sh for generating grub-pc configuration. -- see shy jo
From 280ab997111282639b12e3d6bc8259b5aa670071 Mon Sep 17 00:00:00 2001 From: Joey Hess <j...@kitenet.net> Date: Tue, 29 Nov 2011 13:50:28 -0400 Subject: [PATCH] avoid using otheros.sh for grub-pc otheros.sh does not generate a grub-pc config file, but was used in an edge case for a grub-pc installation when recommends were disabled. Renamed the file to make clear it's only for grub-legacy. Always install os-prober for use by grub-pc, even if recommends are disabled. Closes: #650414 Only run os-prober and generate grub config file when installing grub-legacy. grub-pc does this itself. --- debian/changelog | 9 ++ debian/grub-installer.install | 2 +- grub-installer | 110 ++--------------- grub-legacy.sh | 283 +++++++++++++++++++++++++++++++++++++++++ otheros.sh | 197 ---------------------------- 5 files changed, 302 insertions(+), 299 deletions(-) create mode 100644 grub-legacy.sh delete mode 100644 otheros.sh diff --git a/debian/changelog b/debian/changelog index 6ee9f6f..ce8c9bc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +grub-installer (1.70) UNRELEASED; urgency=low + + * Always install os-prober for use by grub-pc, even if recommends are + disabled. Closes: #650414 + * Only run os-prober and generate grub config file when installing + grub-legacy. grub-pc does this itself. + + -- Joey Hess <jo...@debian.org> Tue, 29 Nov 2011 13:45:53 -0400 + grub-installer (1.69) unstable; urgency=low [ Joey Hess ] diff --git a/debian/grub-installer.install b/debian/grub-installer.install index ec8f6f4..141a95a 100644 --- a/debian/grub-installer.install +++ b/debian/grub-installer.install @@ -1,5 +1,5 @@ rescue.d/* lib/rescue.d grub-installer usr/bin functions.sh usr/share/grub-installer -otheros.sh usr/share/grub-installer +grub-legacy.sh usr/share/grub-installer ensure-active usr/lib/grub-installer diff --git a/grub-installer b/grub-installer index df3b025..8154093 100755 --- a/grub-installer +++ b/grub-installer @@ -13,7 +13,6 @@ else fi . /usr/share/grub-installer/functions.sh -. /usr/share/grub-installer/otheros.sh newline=" " @@ -417,8 +416,10 @@ case "$grub_package" in fi ;; *) - # Will pull in os-prober based on global setting for Recommends apt-install $grub_package || exit_code=$? + # ensure os-prober is installed even if recommends not installed by + # default + apt-install os-prober || exit_code=$? ;; esac @@ -972,105 +973,10 @@ if [ "$serial" ] ; then esac fi -# Generate menu.lst additions for other OSes -tmpfile=/tmp/menu.lst.extras -OLDIFS="$IFS" -IFS="$newline" - -no_floppy="" -if $chroot $ROOT dpkg --compare-versions $grub_debian_version ge 1.96+20090609-1 ; then - no_floppy="--no-floppy" -fi - -for os in $(cat /tmp/os-probed); do - IFS="$OLDIFS" - title=$(echo "$os" | cut -d: -f2) - shortname=$(echo "$os" | cut -d: -f3) - type=$(echo "$os" | cut -d: -f4) - case "$type" in - chain) - partition=$(mapdevfs $(echo "$os" | cut -d: -f1)) - grubdrive=$(convert "$partition") || true - if [ -n "$grubdrive" ]; then - case $grub_version in - grub) grub_write_chain ;; - grub2) grub2_write_chain ;; - esac - fi - ;; - linux) - partition=$(echo "$os" | cut -d: -f1) - mappedpartition=$(mapdevfs "$partition") - IFS="$newline" - for entry in $(linux-boot-prober "$partition"); do - IFS="$OLDIFS" - bootpart=$(echo "$entry" | cut -d: -f2) - mappedbootpart=$(mapdevfs "$bootpart") || true - if [ -z "$mappedbootpart" ]; then - mappedbootpart="$bootpart" - fi - label=$(echo "$entry" | cut -d : -f3) - if [ -z "$label" ]; then - label="$title" - fi - kernel=$(echo "$entry" | cut -d : -f4) - initrd=$(echo "$entry" | cut -d : -f5) - if echo "$kernel" | grep -q '^/boot/' && \ - [ "$mappedbootpart" != "$mappedpartition" ]; then - # separate /boot partition - kernel=$(echo "$kernel" | sed 's!^/boot!!') - initrd=$(echo "$initrd" | sed 's!^/boot!!') - grubdrive=$(convert "$mappedbootpart") || true - else - grubdrive=$(convert "$mappedpartition") || true - fi - params="$(echo "$entry" | cut -d : -f6-) $serial" - case $grub_version in - grub) grub_write_linux ;; - grub2) grub2_write_linux ;; - esac - IFS="$newline" - done - IFS="$OLDIFS" - ;; - hurd) - partition=$(mapdevfs $(echo "$os" | cut -d: -f1)) - grubdrive=$(convert "$partition") || true - hurddrive=$(hurd_convert "$partition") || true - # Use the standard hurd boilerplate to boot it. - case $grub_version in - grub) grub_write_hurd ;; - grub2) grub2_write_hurd ;; - esac - ;; - *) - info "unhandled: $os" - ;; - esac - IFS="$newline" -done -IFS="$OLDIFS" -rm -f /tmp/os-probed - -if [ -s $tmpfile ] ; then - case $grub_version in - grub) - grub_write_divider - cat $tmpfile >> $ROOT/boot/grub/$menu_file - ;; - grub2) - if ! $chroot $ROOT which os-prober >/dev/null 2>&1; then - cat > $ROOT/etc/grub.d/30_otheros << EOF -#!/bin/sh -exec tail -n +3 \$0 -EOF - cat $tmpfile >> $ROOT/etc/grub.d/30_otheros - chmod +x $ROOT/etc/grub.d/30_otheros - update_grub # propagate 30_otheros to grub.cfg - fi - ;; - esac - rm -f $tmpfile +if [ "$grub_version" = grub ]; then + # For grub-legacy, generate menu.lst additions for other OSes. + # (grub2 uses os-prober by itself) + . /usr/share/grub-installer/grub-legacy.sh fi case $ARCH in @@ -1120,3 +1026,5 @@ fi db_progress STEP 1 db_progress STOP + +rm -f /tmp/os-probed diff --git a/grub-legacy.sh b/grub-legacy.sh new file mode 100644 index 0000000..bdfb0e7 --- /dev/null +++ b/grub-legacy.sh @@ -0,0 +1,283 @@ +grub_write_chain() { + cat >> $tmpfile <<EOF + +# This entry automatically added by the Debian installer for a non-linux OS +# on $partition +title $title +EOF + # DOS/Windows often needs rootnoverify so that GRUB doesn't rely on + # mounting the filesystem + case $shortname in + MS*|Win*) + cat >> $tmpfile <<EOF +rootnoverify $grubdrive +EOF + ;; + *) + cat >> $tmpfile <<EOF +root $grubdrive +EOF + ;; + esac + cat >> $tmpfile <<EOF +savedefault +EOF + # Only set makeactive if grub is installed in the mbr + if [ "$bootdev" = "(hd0)" ]; then + cat >> $tmpfile <<EOF +makeactive +EOF + fi + # DOS/Windows can't deal with booting from a non-first hard drive + case $shortname in + MS*|Win*) + grubdisk="$(echo "$grubdrive" | sed 's/^(//; s/)$//; s/,.*//')" + case $grubdisk in + hd0) ;; + hd*) + case $title in + Windows\ Vista*|Windows\ 7*) + ;; + *) + cat >> $tmpfile <<EOF +map (hd0) ($grubdisk) +map ($grubdisk) (hd0) +EOF + ;; + esac + ;; + esac + ;; + esac + cat >> $tmpfile <<EOF +chainloader +1 + +EOF +} # grub_write_chain end + +grub2_write_chain() { + uuid="$($chroot $ROOT grub-probe --target fs_uuid --device $partition)" + cat >> $tmpfile <<EOF + +# This entry automatically added by the Debian installer for a non-linux OS +# on $partition +menuentry "$title" { + set root=$grubdrive +EOF + if [ -n "$uuid" ] ; then + cat >> $tmpfile <<EOF + search $no_floppy --fs-uuid --set $uuid +EOF + fi + # DOS/Windows can't deal with booting from a non-first hard drive + case $shortname in + MS*|Win*) + if $chroot $ROOT dpkg --compare-versions $grub_debian_version gt 1.96+20090609-1 && \ + [ "$title" != "Windows Vista (loader)" ]; then + cat >> $tmpfile <<EOF + drivemap -s (hd0) \$root +EOF + fi + ;; + esac + cat >> $tmpfile <<EOF + chainloader +1 +} +EOF + +} # grub2_write_chain end + +grub_write_linux() { + cat >> $tmpfile <<EOF + +# This entry automatically added by the Debian installer for an existing +# linux installation on $mappedpartition. +title $label (on $mappedpartition) +root $grubdrive +kernel $kernel $params +EOF + if [ -n "$initrd" ]; then + cat >> $tmpfile <<EOF +initrd $initrd +EOF + fi + cat >> $tmpfile <<EOF +savedefault +boot + +EOF +} # grub_write_linux end + +grub2_write_linux() { + cat >> $tmpfile <<EOF + +# This entry automatically added by the Debian installer for an existing +# linux installation on $mappedpartition. +menuentry "$label (on $mappedpartition)" { + set root=$grubdrive +EOF + uuid="$($chroot $ROOT grub-probe --target fs_uuid --device $partition)" + if [ -n "$uuid" ] ; then + cat >> $tmpfile <<EOF + search $no_floppy --fs-uuid --set $uuid +EOF + fi + cat >> $tmpfile <<EOF + linux $kernel $params +EOF + if [ -n "$initrd" ]; then + cat >> $tmpfile <<EOF + initrd $initrd +EOF + fi + cat >> $tmpfile <<EOF +} + +EOF +} # grub2_write_linux end + +grub_write_hurd() { + cat >> $tmpfile <<EOF + +# This entry automatically added by the Debian installer for an existing +# hurd installation on $partition. +title $title (on $partition) +root $grubdrive +kernel /boot/gnumach.gz root=device:$hurddrive +module /hurd/ext2fs.static --readonly \\ + --multiboot-command-line=\${kernel-command-line} \\ + --host-priv-port=\${host-port} \\ + --device-master-port=\${device-port} \\ + --exec-server-task=\${exec-task} -T typed \${root} \\ + \$(task-create) \$(task-resume) +module /lib/ld.so.1 /hurd/exec \$(exec-task=task-create) +savedefault +boot + +EOF +} # grub_write_hurd end + +grub2_write_hurd() { + cat >> $tmpfile <<EOF + +# This entry automatically added by the Debian installer for an existing +# hurd installation on $partition. +menuentry "$title (on $partition)" { + set root=$grubdrive +EOF + uuid="$($chroot $ROOT grub-probe --target fs_uuid --device $partition)" + if [ -n "$uuid" ] ; then + cat >> $tmpfile <<EOF + search $no_floppy --fs-uuid --set $uuid +EOF + fi + cat >> $tmpfile <<EOF + multiboot /boot/gnumach.gz root=device:$hurddrive + module /hurd/ext2fs.static ext2fs --readonly \\ + --multiboot-command-line=\${kernel-command-line} \\ + --host-priv-port=\${host-port} \\ + --device-master-port=\${device-port} \\ + --exec-server-task=\${exec-task} -T typed \${root} \\ + \$(task-create) \$(task-resume) + module /lib/ld.so.1 exec /hurd/exec \$(exec-task=task-create) +} + +EOF +} # grub2_write_hurd end + +grub_write_divider() { + cat >> $ROOT/boot/grub/$menu_file << EOF + +# This is a divider, added to separate the menu items below from the Debian +# ones. +title Other operating systems: +root + +EOF +} # grub_write_divider end + +tmpfile=/tmp/menu.lst.extras +OLDIFS="$IFS" +IFS="$newline" + +no_floppy="" +if $chroot $ROOT dpkg --compare-versions $grub_debian_version ge 1.96+20090609-1 ; then + no_floppy="--no-floppy" +fi + +for os in $(cat /tmp/os-probed); do + IFS="$OLDIFS" + title=$(echo "$os" | cut -d: -f2) + shortname=$(echo "$os" | cut -d: -f3) + type=$(echo "$os" | cut -d: -f4) + case "$type" in + chain) + partition=$(mapdevfs $(echo "$os" | cut -d: -f1)) + grubdrive=$(convert "$partition") || true + if [ -n "$grubdrive" ]; then + case $grub_version in + grub) grub_write_chain ;; + grub2) grub2_write_chain ;; + esac + fi + ;; + linux) + partition=$(echo "$os" | cut -d: -f1) + mappedpartition=$(mapdevfs "$partition") + IFS="$newline" + for entry in $(linux-boot-prober "$partition"); do + IFS="$OLDIFS" + bootpart=$(echo "$entry" | cut -d: -f2) + mappedbootpart=$(mapdevfs "$bootpart") || true + if [ -z "$mappedbootpart" ]; then + mappedbootpart="$bootpart" + fi + label=$(echo "$entry" | cut -d : -f3) + if [ -z "$label" ]; then + label="$title" + fi + kernel=$(echo "$entry" | cut -d : -f4) + initrd=$(echo "$entry" | cut -d : -f5) + if echo "$kernel" | grep -q '^/boot/' && \ + [ "$mappedbootpart" != "$mappedpartition" ]; then + # separate /boot partition + kernel=$(echo "$kernel" | sed 's!^/boot!!') + initrd=$(echo "$initrd" | sed 's!^/boot!!') + grubdrive=$(convert "$mappedbootpart") || true + else + grubdrive=$(convert "$mappedpartition") || true + fi + params="$(echo "$entry" | cut -d : -f6-) $serial" + case $grub_version in + grub) grub_write_linux ;; + grub2) grub2_write_linux ;; + esac + IFS="$newline" + done + IFS="$OLDIFS" + ;; + hurd) + partition=$(mapdevfs $(echo "$os" | cut -d: -f1)) + grubdrive=$(convert "$partition") || true + hurddrive=$(hurd_convert "$partition") || true + # Use the standard hurd boilerplate to boot it. + case $grub_version in + grub) grub_write_hurd ;; + grub2) grub2_write_hurd ;; + esac + ;; + *) + info "unhandled: $os" + ;; + esac + IFS="$newline" +done +IFS="$OLDIFS" + +if [ -s $tmpfile ] ; then + grub_write_divider + cat $tmpfile >> $ROOT/boot/grub/$menu_file + ;; +fi +rm -f $tmpfile + diff --git a/otheros.sh b/otheros.sh deleted file mode 100644 index b861d89..0000000 --- a/otheros.sh +++ /dev/null @@ -1,197 +0,0 @@ -grub_write_chain() { - cat >> $tmpfile <<EOF - -# This entry automatically added by the Debian installer for a non-linux OS -# on $partition -title $title -EOF - # DOS/Windows often needs rootnoverify so that GRUB doesn't rely on - # mounting the filesystem - case $shortname in - MS*|Win*) - cat >> $tmpfile <<EOF -rootnoverify $grubdrive -EOF - ;; - *) - cat >> $tmpfile <<EOF -root $grubdrive -EOF - ;; - esac - cat >> $tmpfile <<EOF -savedefault -EOF - # Only set makeactive if grub is installed in the mbr - if [ "$bootdev" = "(hd0)" ]; then - cat >> $tmpfile <<EOF -makeactive -EOF - fi - # DOS/Windows can't deal with booting from a non-first hard drive - case $shortname in - MS*|Win*) - grubdisk="$(echo "$grubdrive" | sed 's/^(//; s/)$//; s/,.*//')" - case $grubdisk in - hd0) ;; - hd*) - case $title in - Windows\ Vista*|Windows\ 7*) - ;; - *) - cat >> $tmpfile <<EOF -map (hd0) ($grubdisk) -map ($grubdisk) (hd0) -EOF - ;; - esac - ;; - esac - ;; - esac - cat >> $tmpfile <<EOF -chainloader +1 - -EOF -} # grub_write_chain end - -grub2_write_chain() { - uuid="$($chroot $ROOT grub-probe --target fs_uuid --device $partition)" - cat >> $tmpfile <<EOF - -# This entry automatically added by the Debian installer for a non-linux OS -# on $partition -menuentry "$title" { - set root=$grubdrive -EOF - if [ -n "$uuid" ] ; then - cat >> $tmpfile <<EOF - search $no_floppy --fs-uuid --set $uuid -EOF - fi - # DOS/Windows can't deal with booting from a non-first hard drive - case $shortname in - MS*|Win*) - if $chroot $ROOT dpkg --compare-versions $grub_debian_version gt 1.96+20090609-1 && \ - [ "$title" != "Windows Vista (loader)" ]; then - cat >> $tmpfile <<EOF - drivemap -s (hd0) \$root -EOF - fi - ;; - esac - cat >> $tmpfile <<EOF - chainloader +1 -} -EOF - -} # grub2_write_chain end - -grub_write_linux() { - cat >> $tmpfile <<EOF - -# This entry automatically added by the Debian installer for an existing -# linux installation on $mappedpartition. -title $label (on $mappedpartition) -root $grubdrive -kernel $kernel $params -EOF - if [ -n "$initrd" ]; then - cat >> $tmpfile <<EOF -initrd $initrd -EOF - fi - cat >> $tmpfile <<EOF -savedefault -boot - -EOF -} # grub_write_linux end - -grub2_write_linux() { - cat >> $tmpfile <<EOF - -# This entry automatically added by the Debian installer for an existing -# linux installation on $mappedpartition. -menuentry "$label (on $mappedpartition)" { - set root=$grubdrive -EOF - uuid="$($chroot $ROOT grub-probe --target fs_uuid --device $partition)" - if [ -n "$uuid" ] ; then - cat >> $tmpfile <<EOF - search $no_floppy --fs-uuid --set $uuid -EOF - fi - cat >> $tmpfile <<EOF - linux $kernel $params -EOF - if [ -n "$initrd" ]; then - cat >> $tmpfile <<EOF - initrd $initrd -EOF - fi - cat >> $tmpfile <<EOF -} - -EOF -} # grub2_write_linux end - -grub_write_hurd() { - cat >> $tmpfile <<EOF - -# This entry automatically added by the Debian installer for an existing -# hurd installation on $partition. -title $title (on $partition) -root $grubdrive -kernel /boot/gnumach.gz root=device:$hurddrive -module /hurd/ext2fs.static --readonly \\ - --multiboot-command-line=\${kernel-command-line} \\ - --host-priv-port=\${host-port} \\ - --device-master-port=\${device-port} \\ - --exec-server-task=\${exec-task} -T typed \${root} \\ - \$(task-create) \$(task-resume) -module /lib/ld.so.1 /hurd/exec \$(exec-task=task-create) -savedefault -boot - -EOF -} # grub_write_hurd end - -grub2_write_hurd() { - cat >> $tmpfile <<EOF - -# This entry automatically added by the Debian installer for an existing -# hurd installation on $partition. -menuentry "$title (on $partition)" { - set root=$grubdrive -EOF - uuid="$($chroot $ROOT grub-probe --target fs_uuid --device $partition)" - if [ -n "$uuid" ] ; then - cat >> $tmpfile <<EOF - search $no_floppy --fs-uuid --set $uuid -EOF - fi - cat >> $tmpfile <<EOF - multiboot /boot/gnumach.gz root=device:$hurddrive - module /hurd/ext2fs.static ext2fs --readonly \\ - --multiboot-command-line=\${kernel-command-line} \\ - --host-priv-port=\${host-port} \\ - --device-master-port=\${device-port} \\ - --exec-server-task=\${exec-task} -T typed \${root} \\ - \$(task-create) \$(task-resume) - module /lib/ld.so.1 exec /hurd/exec \$(exec-task=task-create) -} - -EOF -} # grub2_write_hurd end - -grub_write_divider() { - cat >> $ROOT/boot/grub/$menu_file << EOF - -# This is a divider, added to separate the menu items below from the Debian -# ones. -title Other operating systems: -root - -EOF -} # grub_write_divider end -- 1.7.7.3
signature.asc
Description: Digital signature