Bug#568835: grub-install: incorrect handling of return value from grub-probe -t

Vincent McIntyre Vince.McIntyre at atnf.csiro.au
Mon Feb 8 03:56:05 UTC 2010


Package: grub-common
Version: 1.96+20080724-16
Severity: important
Tags: patch

*** Please type your report below this line ***

During an installation, I had a problem with the grub step.
The system is going to be set up with the '/' partition on a
software raid device, /dev/md0. /boot will be within this partition.
But that's not really relevant to the bug in question.


I tried running grub-install manually from an installer shell:

  # chroot /target /usr/sbin/grub-install /dev/md0

and the program died with:
  Searching for GRUB installation directory ... found: /boot/grub
  grub-probe: error: no mapping exists for `md0'
  /usr/sbin/grub-install: line 374: [: =: unary operator expected


This appears to be occurring because of a comparison to a backticked
expression that can return a null or empty string:

  # On XFS, sync() is not enough.
  if [ `grub-probe -t fs ${grubdir}` = "xfs" ] ; then
    xfs_freeze -f ${grubdir} && xfs_freeze -u ${grubdir}
    # We don't have set -e.  If xfs_freeze failed, it's worth trying anyway,
    # maybe we're lucky.
  fi

The fix for this would appear to be this patch:

--- /usr/sbin/grub-install      2009-01-17 08:26:27.000000000 +1100
+++ /tmp/grub-install   2010-02-08 14:28:09.000000000 +1100
@@ -371,7 +371,7 @@
 sync

 # On XFS, sync() is not enough.
-if [ `grub-probe -t fs ${grubdir}` = "xfs" ] ; then
+if [ "`grub-probe -t fs ${grubdir}`" = "xfs" ] ; then
   xfs_freeze -f ${grubdir} && xfs_freeze -u ${grubdir}
   # We don't have set -e.  If xfs_freeze failed, it's worth trying
anyway,
   # maybe we're lucky.


This affects debian stable, and installation of debian stable.
It may affect later versions of grub-common, I have not checked.
It may not affect all installation instances, but it seems to affect
things in the case of root-on-raid.

Kind regards
Vince

-- System Information:
Debian Release: 5.0.3
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.26-2-686 (SMP w/4 CPU cores)
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.iso88591 (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/bash

Versions of packages grub-common depends on:
ii  base-files                  5lenny4      Debian base system
miscellaneous f
ii  libc6                       2.7-18lenny2 GNU C Library: Shared
libraries

grub-common recommends no packages.

Versions of packages grub-common suggests:
pn  multiboot-doc                 <none>     (no description available)

-- no debconf information








More information about the Pkg-grub-devel mailing list