#651512 grub-pc: debconf's 'grub/install_devices' refers to device IDs while debconf shows device names

Package:
grub-pc
Source:
grub2
Description:
GRand Unified Bootloader, version 2 (PC/BIOS version)
Submitter:
Luca Capello
Date:
2011-12-09 11:36:19 UTC
Severity:
important
#651512#5
Date:
2011-12-09 11:31:39 UTC
From:
To:
Hi there!

This could be a duplicate of #650724, but given that the error shown is
different, I reported it as a new bug.

I changed both 500GB Samsung HDs with two 1TB Seagate HDs (in RAID1, LV
for /), in series: changed the first, rebuilt the RAID1, checked that
everything was OK, reconfigured grub-pc for the new disk and then
started again for the second, but it seems I missed the second
'dpkg-reconfigure grub-pc' step and the last kernel upgrade fails:
=====
tinello:/etc# apt-get update
[...]

tinello:/etc# apt-get upgrade
[...]
The following packages will be upgraded:
  linux-image-2.6.32-5-amd64
[...]
Preconfiguring packages ...
(Reading database ... 133332 files and directories currently installed.)
Preparing to replace linux-image-2.6.32-5-amd64 2.6.32-38 \
 (using .../linux-image-2.6.32-5-amd64_2.6.32-39_amd64.deb) ...
Unpacking replacement linux-image-2.6.32-5-amd64 ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.32-5-amd64 \
 /boot/vmlinuz-2.6.32-5-amd64
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.32-5-amd64 \
 /boot/vmlinuz-2.6.32-5-amd64
Setting up linux-image-2.6.32-5-amd64 (2.6.32-39) ...
Running depmod.
Running update-initramfs.
update-initramfs: deferring update (hook will be called later)
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 2.6.32-5-amd64 \
 /boot/vmlinuz-2.6.32-5-amd64
update-initramfs: Generating /boot/initrd.img-2.6.32-5-amd64
run-parts: executing /etc/kernel/postinst.d/pm-utils 2.6.32-5-amd64 \
 /boot/vmlinuz-2.6.32-5-amd64
run-parts: executing /etc/kernel/postinst.d/update-notifier 2.6.32-5-amd64 \
 /boot/vmlinuz-2.6.32-5-amd64
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 2.6.32-5-amd64 \
 /boot/vmlinuz-2.6.32-5-amd64
Generating grub.cfg ...
/usr/sbin/grub-probe: error: no such disk.
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 1
Failed to process /etc/kernel/postinst.d at \
 /var/lib/dpkg/info/linux-image-2.6.32-5-amd64.postinst line 799.
dpkg: error processing linux-image-2.6.32-5-amd64 (--configure):
 subprocess installed post-installation script returned error exit status 2
configured to not write apport reports
Errors were encountered while processing:
 linux-image-2.6.32-5-amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)

tinello:/etc# uname -a
Linux tinello 3.0.0-1-amd64 #1 SMP Sat Aug 27 16:21:11 UTC 2011 x86_64 GNU/Linux

tinello:/etc# dpkg-reconfigure grub-pc
[...]

  ┌─────────────────────┤ Configuring grub-pc ├─────────────────────┐
  │ The GRUB boot loader was previously installed to a disk that is │
  │ no longer present, or whose unique identifier has changed for   │
  │ some reason. [...]                                              │
[...]
  │ GRUB install devices:                                           │
  │                                                                 │
  │    [*] /dev/sda (1000204 MB; ST31000524AS)                      │
  │    [*] /dev/sdb (1000204 MB; ST31000524AS)                      │
  │    [ ] /dev/dm-0 (491903 MB; tinello-root)                      │
  │    [ ] /dev/md0 (199 MB; tinello:0)                             │
[...]

/usr/sbin/grub-probe: error: no such disk.
Auto-detection of a filesystem of /dev/md0 failed.
Please report this together with the output of "/usr/sbin/grub-probe \
 --device-map=/boot/grub/device.map --target=fs -v /boot/grub" to <bug-grub@gnu.org>
/usr/sbin/grub-probe: error: no such disk.
Auto-detection of a filesystem of /dev/md0 failed.
Please report this together with the output of "/usr/sbin/grub-probe \
 --device-map=/boot/grub/device.map --target=fs -v /boot/grub" to <bug-grub@gnu.org>

Package configuration

  ┌─────────────────────┤ Configuring grub-pc ├─────────────────────┐
  │                                                                 │
  │ GRUB failed to install to the following devices:                │
  │                                                                 │
  │ /dev/sda /dev/sdb                                               │
[...]

Generating grub.cfg ...
/usr/sbin/grub-probe: error: no such disk.

tinello:/etc# debconf-show grub-pc
  grub2/kfreebsd_cmdline:
  grub2/device_map_regenerated:
* grub2/linux_cmdline:
  grub-pc/install_devices_empty: false
  grub-pc/install_devices_failed: false
  grub-pc/chainload_from_menu.lst: true
  grub-pc/kopt_extracted: false
* grub-pc/install_devices: \
   /dev/disk/by-id/ata-ST31000524AS_6VPC7CTQ, \
   /dev/disk/by-id/ata-SAMSUNG_HD502HJ_S20BJ9FB109405
  grub-pc/postrm_purge_boot_grub: false
  grub-pc/install_devices_failed_upgrade: true
  grub-pc/disk_description:
  grub2/kfreebsd_cmdline_default: quiet
  grub-pc/partition_description:
* grub-pc/install_devices_disks_changed: \
   /dev/disk/by-id/ata-ST31000524AS_6VPC7CTQ, \
   /dev/disk/by-id/ata-SAMSUNG_HD502HJ_S20BJ9FB109405
* grub2/linux_cmdline_default: quiet
  grub-pc/mixed_legacy_and_grub2: true

tinello:/etc# /usr/sbin/grub-probe --device-map=/boot/grub/device.map \
 --target=fs -v /boot/grub
/usr/sbin/grub-probe: info: Cannot stat `/dev/disk/by-id/ata-SAMSUNG_HD502HJ_S20BJ9FB109400', skipping.
/usr/sbin/grub-probe: info: Cannot stat `/dev/disk/by-id/ata-SAMSUNG_HD502HJ_S20BJ9FB109405', skipping.
/usr/sbin/grub-probe: info: changing current directory to /dev.
/usr/sbin/grub-probe: info: changing current directory to usb.
/usr/sbin/grub-probe: info: changing current directory to dri.
/usr/sbin/grub-probe: info: changing current directory to snd.
/usr/sbin/grub-probe: info: changing current directory to by-path.
/usr/sbin/grub-probe: info: changing current directory to cpu.
/usr/sbin/grub-probe: info: changing current directory to shm.
/usr/sbin/grub-probe: info: changing current directory to tinello.
/usr/sbin/grub-probe: info: opening md/0.
/usr/sbin/grub-probe: error: no such disk.

tinello:/etc#
=====

I think we have two problems here:

1) device.map is not in sync with the current situation, which means
   that a simple `grub-mkdevicemap` should solve this.

2) however, debconf's 'grub-pc/install_devices' is not in sync either
   and `dpkg-reconfigure grub-pc` does not solve it, while IMHO it
   should.

   I think there is a fundamental problem here: grub-pc's debconf mixes
   device names (/dev/sda) with device IDs (/dev/disk/by-id/...).  This
   means that while you think you chose device names (so changing disks
   should not cause any problem), what is actually used is device IDs,
   which are not updated *before* starting grub-probe (so your choice is
   not taken into account).

   Indeed, updating this line was enough to solve the problem:
=====
tinello:/etc# echo "grub-pc grub-pc/install_devices string \
 /dev/disk/by-id/ata-ST31000524AS_6VPC7CTQ, \
 /dev/disk/by-id/ata-ST31000524AS_9VPCW9CS" | debconf-set-selections

tinello:/etc# dpkg-reconfigure grub-pc
[...]

  ┌─────────────────────┤ Configuring grub-pc ├─────────────────────┐
  │ The GRUB boot loader was previously installed to a disk that is │
  │ no longer present, or whose unique identifier has changed for   │
  │ some reason. [...]                                              │
[...]
  │ GRUB install devices:                                           │
  │                                                                 │
  │    [*] /dev/sda (1000204 MB; ST31000524AS)                      │
  │    [*] /dev/sdb (1000204 MB; ST31000524AS)                      │
  │    [ ] /dev/dm-0 (491903 MB; tinello-root)                      │
  │    [ ] /dev/md0 (199 MB; tinello:0)                             │
[...]

Installation finished. No error reported.                                                                                     Installation finished. No error reported.
Generating grub.cfg ...
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-3.0.0-1-amd64
Found initrd image: /boot/initrd.img-3.0.0-1-amd64
Found linux image: /boot/vmlinuz-2.6.39-2-amd64
Found initrd image: /boot/initrd.img-2.6.39-2-amd64
Found linux image: /boot/vmlinuz-2.6.32-5-amd64
Found initrd image: /boot/initrd.img-2.6.32-5-amd64
done

root@tinello:/etc# debconf-show grub-pc
  grub2/kfreebsd_cmdline:
  grub2/device_map_regenerated:
* grub2/linux_cmdline:
  grub-pc/install_devices_empty: false
  grub-pc/install_devices_failed: false
  grub-pc/chainload_from_menu.lst: true
  grub-pc/kopt_extracted: false
* grub-pc/install_devices: \
   /dev/disk/by-id/ata-ST31000524AS_6VPC7CTQ, \
   /dev/disk/by-id/ata-ST31000524AS_9VPCW9CS
  grub-pc/postrm_purge_boot_grub: false
  grub-pc/install_devices_failed_upgrade: true
  grub-pc/disk_description:
  grub2/kfreebsd_cmdline_default: quiet
  grub-pc/partition_description:
* grub-pc/install_devices_disks_changed: \
   /dev/disk/by-id/ata-ST31000524AS_6VPC7CTQ, \
   /dev/disk/by-id/ata-ST31000524AS_9VPCW9CS
* grub2/linux_cmdline_default: quiet
  grub-pc/mixed_legacy_and_grub2: true

tinello:/etc# cat /boot/grub/device.map
(hd0)   /dev/disk/by-id/ata-ST31000524AS_6VPC7CTQ
(hd1)   /dev/disk/by-id/ata-ST31000524AS_9VPCW9CS

tinello:/etc# apt-get -f install
[...]
1 not fully installed or removed.
[...]
Setting up linux-image-2.6.32-5-amd64 (2.6.32-39) ...
Running depmod.
Running update-initramfs.
update-initramfs: deferring update (hook will be called later)
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 2.6.32-5-amd64 \
 /boot/vmlinuz-2.6.32-5-amd64
update-initramfs: Generating /boot/initrd.img-2.6.32-5-amd64
run-parts: executing /etc/kernel/postinst.d/pm-utils 2.6.32-5-amd64 \
 /boot/vmlinuz-2.6.32-5-amd64
run-parts: executing /etc/kernel/postinst.d/update-notifier 2.6.32-5-amd64 \
 /boot/vmlinuz-2.6.32-5-amd64
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 2.6.32-5-amd64 \
 /boot/vmlinuz-2.6.32-5-amd64
Generating grub.cfg ...
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-3.0.0-1-amd64
Found initrd image: /boot/initrd.img-3.0.0-1-amd64
Found linux image: /boot/vmlinuz-2.6.39-2-amd64
Found initrd image: /boot/initrd.img-2.6.39-2-amd64
Found linux image: /boot/vmlinuz-2.6.32-5-amd64
Found initrd image: /boot/initrd.img-2.6.32-5-amd64
done

tinello:/etc#
=====

Thx, bye,
Gismo / Luca