On Tue, Apr 29, 2008 at 11:04:21AM -0700, Mike Bird wrote: > Package: grub > Version: 0.97-37 > Severity: critical > Justification: breaks the whole system > > > "grub-install '(hd0)'" reports "The file /boot/grub/stage1 not read > correctly." > > The problem occurs when grub-install is using dump for some kind > of verification. The log is written to /tmp file with a random > name: > > # cat grubJM5Q31 > > > GNU GRUB version 0.97 (640K lower / 3072K upper memory) > > [ Minimal BASH-like line editing is supported. For > the first word, TAB lists possible command > completions. Anywhere else TAB lists the possible > completions of a device/filename. ] > grub> dump (md0)/grub/stage1 /tmp/grubrakRL1 > > Error 23: Error while parsing number
Please could you test the attached patch? -- Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call… if you are unable to speak? (as seen on /.)
--- util/grub-install 2008-04-26 19:38:51.000000000 +0200 +++ /tmp/grub-install 2008-04-30 12:37:34.000000000 +0200 @@ -125,11 +125,57 @@ sed -n 1p } +## borrowed from update-grub +# Usage: convert_raid1 os_device +# Checks if os_device is a software raid1. +# If so, converts to first physical device in array. +convert_raid1 () +{ + case $1 in + /dev/md[0-9] | /dev/md/[0-9]) + : ;; # Continue + *) + return 1 ;; + esac + + [ -x /sbin/mdadm ] || return 1 + + # Check that the raid device is raid1 + raidlevel=$(mdadm -D -b $1 | grep "^ARRAY" | \ + sed "s/^.*level=//" | cut -d" " -f1) + [ "$raidlevel" = "raid1" ] || return 1 + + # Take only the first device that makes up the raid + raiddev=$(mdadm -D $1 | grep -A1 "Number" | grep "dev" \ + | sed "s/^.*\(\/dev\/.*\)$/\1/") + [ -n "$raiddev" ] || return 1 + + echo $raiddev + return 0 +} + +## borrowed from update-grub (renamed from convert) +# Usage: convert_nonraid os_device +# Convert an OS device to the corresponding GRUB drive. +convert_nonraid () { + if ! test -e ${device_map} ; then + echo quit | grub --batch --no-floppy --device-map=${device_map} > /dev/null + fi + GRUB_LEGACY_0_BASED_PARTITIONS=1 grub-probe --device-map=${device_map} -t drive -d "$1" +} + +## borrowed from update-grub (renamed from convert_default) # Usage: convert os_device # Convert an OS device to the corresponding GRUB drive. -# This part is OS-specific. convert () { - GRUB_LEGACY_0_BASED_PARTITIONS=1 grub-probe --device-map=${device_map} -t drive -d "$1" + # Check if device is software raid1 array + if tmp_dev=$(convert_raid1 $1 2>/dev/null) ; then + : # Use device returned by convert_raid1 + else + tmp_dev=$1 + fi + + convert_nonraid $tmp_dev } # Usage: resolve_symlink file