#595340 grub-pc: upgrade-from-grub-legacy can make system unbootable

Package:
grub-pc
Source:
grub2
Description:
GRand Unified Bootloader, version 2 (PC/BIOS version)
Submitter:
Vincent McIntyre
Date:
2010-09-06 06:06:05 UTC
Severity:
important
#595340#5
Date:
2010-09-02 06:46:06 UTC
From:
To:
Today I did a dist-upgrade from lenny to squeeze.
The short version is: it worked, until I ran upgrade-from-grub-legacy.
That left the system in an unbootable state, see the end of the report.

This bug should probably be cloned against
package: grub-pc, version: 1.98+20100804-2
and closed for d-i, as far as I can tell, d-i its job ok.

Cheers
Vince

My procedure was this:

 ( I would have changed my procedure to match the upgrade guide,
   if I could find it... could we please have a link to the alioth version
   from http://www.debian.org/releases/squeeze/, with whatever caveats are
   necessary ? )


 # <modify sources.list>
 # apt-get update

 # apt-get install apt
 Reading package lists... 0%
 ... Error!
 E: Dynamic MMap ran out of room. Please increase the size of APT::Cache-Limit. Current value: 12500000. (man 5 apt.conf)

 # <set value to 22500000>
 # <remove volatile from sources.list>
 # apt-get update
 # apt-get install apt
 <this works>

 # apt-get upgrade
 <this works>
 # apt-get dist-upgrade
  <this mostly works.

   Somehow, grub-pc failed to install completely. See below.
   It did prompt me about using the 'chainload grub2' option, which I accepted.

   I found that #545292 is still there, after a year.
   It would really help to show what options grub-pc plans to append
   to the boot line, or just show the entire boot line (in readonly form).
   I entered some unneeded options (but removed them later, before rebooting).

   When libc6 is installed, perl starts spamming about locales:
   perl: warning: Setting locale failed.
   perl: warning: Please check that your locale settings:
     etc, etc.
   I guess this is a known issue.

   The upgrade then fails on udev, which is bug #571255.
   md is in a tough spot here, failing at the preinst is reasonable.
   I would like to make it easier for the user to figure out what their
   next action should be. The main thing missing is that one needs to
   boot into a kernel that has CONFIG_SYSFS_DEPRECATED off, before
   attempting to upgrade udev.

 # dpkg -l |grep grub
 ii  grub                                0.97-47lenny2                GRand Unified Bootloader (Legacy version)
 ii  grub-common                         1.96+20080724-16             GRand Unified Bootloader, version 2 (common
 #  dpkg -l grub-pc
  Desired=Unknown/Install/Remove/Purge/Hold
 | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
 |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
 ||/ Name           Version        Description
 +++-==============-==============-============================================
 un  grub-pc        <none>         (no description available)

 # dpkg -l |grep linux-image
 ii  linux-image-2.6-amd64               2.6.26+17+lenny1             Linux 2.6 image on AMD64
 ii  linux-image-2.6.26-2-amd64          2.6.26-24lenny1              Linux 2.6.26 image on AMD64
 iU  linux-image-2.6.32-5-amd64          2.6.32-20                    Linux 2.6.32 for 64-bit PCs

 # apt-get upgrade
 ...
 You might want to run `apt-get -f install' to correct these.
 The following packages have unmet dependencies:
   insserv: Breaks: sysv-rc (< 2.87dsf-3) but 2.86.ds1-61 is installed
 E: Unmet dependencies. Try using -f.

 # apt-get dist-upgrade
 ...
 You might want to run `apt-get -f install' to correct these.
 The following packages have unmet dependencies:
   insserv: Breaks: sysv-rc (< 2.87dsf-3) but 2.86.ds1-61 is installed
 E: Unmet dependencies. Try using -f.

 # apt-get install sysv-rc
 <installs sysv-rc ok. A bunch of other packages get set up as well>

 # apt-get install firmware-bnx2
 # <dpkg -l |grep -v ^ii> shows the installed packages are in ok state

 # apt-get dist-upgrade
 < udev exits again, but more packages get upgraded (eg python-minimal) >
 < the locale spam has gone away >

 # grep CONFIG_SYSFS_DEPRECATED /boot/config*
 /boot/config-2.6.26-2-amd64:CONFIG_SYSFS_DEPRECATED=y
 /boot/config-2.6.26-2-amd64:CONFIG_SYSFS_DEPRECATED_V2=y
 /boot/config-2.6.32-5-amd64:# CONFIG_SYSFS_DEPRECATED_V2 is not set

 # dpkg -l|grep grub
 iU  grub                                0.97-61                      GRand Unified Bootloader (dummy package)
 iU  grub-common                         1.98+20100804-2              GRand Unified Bootloader, version 2 (common
 iU  grub-pc                             1.98+20100804-2              GRand Unified Bootloader, version 2 (PC/BIOS

 # ls /boot/grub
 default        fat_stage1_5  menu.lst~          stage1
 device.map     jfs_stage1_5  minix_stage1_5     stage2
 e2fs_stage1_5  menu.lst      reiserfs_stage1_5  xfs_stage1_5

 # apt-get dist-upgrade
 <just udev left now, fails at once>
 # dpkg-reconfigure grub-common
 /usr/sbin/dpkg-reconfigure: grub-common is broken or not fully installed
 # apt-get install grub-common
 < already at latest version, but other packages get set up (eg cpio, info) >
 < here linux-image-2.6-amd64 (2.6.32+28) gets set up >
 < also, this:
  ...
  Setting up grub-common (1.98+20100804-2) ...
  Setting up grub-pc (1.98+20100804-2) ...
  Removing update-grub hooks from /etc/kernel-img.conf in favour of
  /etc/kernel/ hooks.

  Creating config file /etc/default/grub with new version
  Generating core.img
  Saving menu.lst backup in /boot/grub/menu.lst_backup_by_grub2_postinst
  Running update-grub Legacy to hook our core.img in it
    Searching for GRUB installation directory ... found: /boot/grub
    Searching for default file ... found: /boot/grub/default
    Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
    Searching for splash image ... none found, skipping ...
    Found GRUB 2: /boot/grub/core.img
    Found kernel: /boot/vmlinuz-2.6.32-5-amd64
    Found kernel: /boot/vmlinuz-2.6.26-2-amd64
    Updating /boot/grub/menu.lst ... done

  Generating grub.cfg ...
  Found linux image: /boot/vmlinuz-2.6.32-5-amd64
  Found initrd image: /boot/initrd.img-2.6.32-5-amd64
  Found linux image: /boot/vmlinuz-2.6.26-2-amd64
  Found initrd image: /boot/initrd.img-2.6.26-2-amd64
  Setting up grub (0.97-61) ...
  Setting up libdevmapper-dev (2:1.02.48-3) ...
  Setting up libparted0debian1 (2.3-1) ...
  ...
  Processing triggers for initramfs-tools ...
  update-initramfs: Generating /boot/initrd.img-2.6.32-5-amd64

  # apt-get dist-upgrade
  < fails on udev again >

  # ls -l /boot/grub
  -rw-r--r-- 1 root root    8208 Sep  2 10:55 915resolution.mod
  -rw-r--r-- 1 root root   10484 Sep  2 10:55 acpi.mod
  -rw-r--r-- 1 root root    4580 Sep  2 10:55 affs.mod
  -rw-r--r-- 1 root root    4896 Sep  2 10:55 afs_be.mod
  -rw-r--r-- 1 root root    4880 Sep  2 10:55 afs.mod
  ...
 # dpkg -l |grep grub^M
 ii  grub                                0.97-61                      GRand Unified Bootloader (dummy package)
 ii  grub-common                         1.98+20100804-2              GRand Unified Bootloader, version 2 (common
 ii  grub-pc                             1.98+20100804-2              GRand Unified Bootloader, version 2 (PC/BIOS

 # dpkg -l |grep udev
 ii  udev           0.125-7+lenny3 /dev/ and hotplug management daemon

 <check grub.cfg looks ok>

 # vi /etc/default/grub  # fix erroneous GRUB_CMDLINE_LINUX
 # update-grub
 Generating grub.cfg ...
 Found linux image: /boot/vmlinuz-2.6.32-5-amd64
 Found initrd image: /boot/initrd.img-2.6.32-5-amd64
 Found linux image: /boot/vmlinuz-2.6.26-2-amd64
 Found initrd image: /boot/initrd.img-2.6.26-2-amd64

 <at this point, everything looks ok with the grub config.
  I kept a copy, if that is helpful>

 # reboot
 <select the 'chainload grub2' item at the top of the grub menu

 # uname -a
 Linux install 2.6.32-5-amd64 #1 SMP Thu Aug 12 13:01:50 UTC 2010 x86_64 GNU/Linux

 # apt-get dist-upgrade
 < udev upgrades >
 Preparing to replace udev 0.125-7+lenny3 (using .../archives/udev_160-1_amd64.deb) ...
 unrecognized command 'log-priority=0'
 Unpacking replacement udev ...
 Processing triggers for man-db ...
 Setting up udev (160-1) ...
 Installing new version of config file /etc/init.d/udev-mtab ...
 Installing new version of config file /etc/init.d/udev ...
 Installing new version of config file /etc/udev/links.conf ...
 Installing new version of config file /etc/udev/udev.conf ...
 update-initramfs: deferring update (trigger activated)
 Processing triggers for initramfs-tools ...
 update-initramfs: Generating /boot/initrd.img-2.6.32-5-amd64

 # apt-get update
 # apt-get dist-upgrade
 <nothing to do>

 # reboot
 < select chainload grub2, works >

 # upgrade-from-grub-legacy
 < for some reason I chose /dev/sdc1 instead of /dev/sdc >
 /usr/sbin/grub-setup: warn: Attempting to install GRUB to a partition instead of the MBR.  This is a BAD idea..
 /usr/sbin/grub-setup: warn: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
 Installation finished. No error reported.
 Generating grub.cfg ...
 Found linux image: /boot/vmlinuz-2.6.32-5-amd64
 Found initrd image: /boot/initrd.img-2.6.32-5-amd64
 Found linux image: /boot/vmlinuz-2.6.26-2-amd64
 Found initrd image: /boot/initrd.img-2.6.26-2-amd64
 done

 GRUB Legacy has been removed, but...

 # upgrade-from-grub-legacy
 < this time, select /dev/sdc >
 Installation finished. No error reported.
 Generating grub.cfg ...
 Found linux image: /boot/vmlinuz-2.6.32-5-amd64
 Found initrd image: /boot/initrd.img-2.6.32-5-amd64
 Found linux image: /boot/vmlinuz-2.6.26-2-amd64
 Found initrd image: /boot/initrd.img-2.6.26-2-amd64
 done

 GRUB Legacy has been removed, but...

 # dd if=/dev/sdc bs=512 count=2 |od -c
 <I can supply this if required>


 # reboot

 GRUB loading stage 1.5.

 GRUB loading, please wait...
 Error 15

 I booted a weekly-snapshot install disk (30-Aug-2010 06:57 md5sum 2728f9018b5e76db1458b946ca139342)
 and attempted to do this in rescue mode:
 <mount /dev/sdb1 as root partition>
 <start a shell in root partition>
 # /etc/init.d/lvm2 start
 # mount /usr
 # sh -x /usr/sbin/grub-install /dev/sdb
 # reboot

 But I get the same error.

Happy to dig into this a bit if someone can help me get the system booting.

#595340#10
Date:
2010-09-02 13:43:01 UTC
From:
To:
The internal disks are SATA, and I have some 'scsi' devices connected,
over fibre channel.
I don't think hda/sda device naming is the problem though, if that's
what you mean. I am pretty sure I installed grub to the right device.

I don't get the grub menu displayed.

No. There are 6 internal disks, and three FC-connected external disks.
I am using what the BIOS thinks is the second disk.

I think I've tried the equivalent of this, booting the squeeze installer
in rescue mode and mounting the root partition, so I could try running
grub-install. The kernel definitely sees the disks and mounts the one I
wanted ok.

Thanks,
Vince

#595340#15
Date:
2010-09-03 08:14:04 UTC
From:
To:
So I attempted to reinstall grub to the MBR following these sources:
https://help.ubuntu.com/community/Grub2
https://wiki.ubuntu.com/Grub2
No dice.

I tried the following -
 * with the installer cd in 'rescue' mode
   * mount /dev/sdb1  (which contains /boot)
   * start a shell in /dev/sdb1
   * mounting /var and /usr
   * run dpkg-reconfigure grub-pc (also tried rerunning grub-install).
   * exit shell and reboot
   All seemed to go well but I get the same "Error 15" when rebooting.

 * with the installer cd in  'install' mode
   * get as far as partitioning
   * start a shell
   * mount /dev/sdb1 /mnt
   * build up a chroot as per the ubuntu links above.
   * chroot
   * mount /var, /usr
   * run grub-install /dev/sdb
   * umount /var, /usr
   * exit shell, umount the other elements of the chroot
   * reboot
   All seemed to go well but I get the same "Error 15" when rebooting.

 * with the installer cd in  'install' mode
   * as above but once inside the chroot,
     * apt-get --purge remove grub-pc
     * cd /var/cache/apt/archives
     * dpkg -i grub-pc*.deb
     * dpkg -i grub_0.97*.deb  (the compatibility package)
     * then umount, exit chroot, umount and reboot.
   All seemed to go well but I get the same "Error 15" when rebooting.

 * I thought of following the recipe given in #547944 but realised that
   purging and reinstalling should amount to the same thing.

 * I checked the device map file and it was correct, hd1 maps to the
   right link in /dev/disk/by-id, ending up at /dev/sdb.
 * I checked /dev/sdb was being modified by grub-install.
   According to the timestamp, it is.

When examining the grub.cfg, I notice that it tries to load files from
/usr/share as almost the first thing it does. Pretty font files. Sigh.
Is there any way I can turn this off?

#595340#26
Date:
2010-09-06 05:49:55 UTC
From:
To:
This turned out to be a problem with one of the other disks in the system.

The first disk in the chassis, which is enumerated as /dev/sda,
contains a Dell utility partition. This uses linux under the hood,
and of course has a GRUB setup in the MBR.

I was working with the second disk in the chassis (enumerated as /dev/sdb).

The tests that showed this were as follows.
 - remove all disks except the intended boot disk (sdb).
   power up, I see 'Welcome to GRUB!' and the correct grub menu loads.
   system boots ok.
   power down.
 - start adding the other disks back one at a time, boots every time.
 - add the disk with the Dell utilities (sda).
   power up, grub fails with 'Error 15'.
   power down.
 - remove the disk with the Dell utilities.
   power up, I see 'Welcome to GRUB!' and the correct grub menu loads.
 - I checked the MBR of the sda disk with dd if=/dev/sda bs=512 | od -c.
   This shows GRUB installed on the MBR of the disk. I didn't put it there.

It appears that upgrade-grub-from-legacy was getting confused, somehow,
by the two grub signatures in the MBRs.

So I'm not sure if this is still a bug in grub-pc, or a 'feature'.
I'll wait for the maintainer's opinion on that.

I am surprised grub-install did not detect and warn about the grub signature
on the other disk, particularly as it was earlier in the enumeration order.

The signature on sdb should definitely have been grub2.
I couldn't tell if the signature on sda was grub1.
How would one tell them apart?

I am guessing upgrade-grub-from-legacy does not check for grub1 signatures
on all disks in the system, but just updates the first one it finds, or
just the one mentioned in /boot/grub/grub.cfg.
It would be more robust to check all the disks, if this is possible,
and warn the user if more than one signature is found.

My thanks to Zoltan Herman for pointing me in the right direction
by private mail.