Bug#441080: grub-install shouldn't rely on /etc/mtab (via df) to find out the root partition

Raphael Hertzog hertzog at debian.org
Thu Sep 6 15:02:32 UTC 2007


Package: grub
Version: 0.97-29
Severity: normal

I was doing some partition handling on my laptop and due to that my root
partition got renumbered (hda6 -> hda5). When I rebooted Grub failed to
load so I started on a Debian CD in rescue mode.

When I wanted to re-run 'grub-install (hd0)' it failed with:
The file /boot/grub/stage1 not read correctly.

First the message is not correct english, it lacks a verb. And even then,
it's not clear what's wrong. Apparently it uses grub to extract the file
that he just put in place and verify that they are the same.

The underlying problem was that it wasn't able to extract the file because
find_device uses "df" to find out the partition associated to a given directory
and df in turn uses /etc/mtab.

In that case, since I was in an emergency shell, /etc/mtab wasn't properly
updated and furthermore it contained outdated information pointing to the
old name of the root filesystem.

I had /proc mounted and it should have used /proc/mounts to identify the
device before eventually falling back to something else like df.


For reference, here's the code that I'm referring to:

find_device () {
    # For now, this uses the program `df' to get the device name, but is
    # this really portable?
    tmp_fname=`df $1/ | sed -n 's%.*\(/dev/[^   ]*\).*%\1%p'`

[...]

# Get the root drive.
root_device=`find_device ${rootdir}`


Cheers,

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.22-1-686 (SMP w/1 CPU core)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages grub depends on:
ii  libc6                     2.6.1-2        GNU C Library: Shared libraries
ii  libncurses5               5.6+20070825-1 Shared libraries for terminal hand

grub recommends no packages.

-- no debconf information




More information about the Pkg-grub-devel mailing list