[Bug 1803805] Re: grub-pc fails to install on the last of multiple devices

Paul White 1803805 at bugs.launchpad.net
Sat Nov 17 13:05:38 UTC 2018


Richard, as you didn't use 'apport' or 'ubuntu-bug' when creating this
bug report I'm unsure if what you are reporting applies to me or not as
your report doesn't include any version information.

I have Ubuntu 18.04 and Ubuntu 19.04 installed on this laptop which has
two disks /dev/sda and /dev/sdb. Using Ubuntu 18.04 I can install grub,
update grub and boot to either installation without any problem.

>From Ubuntu 18.10 (now upgraded to Ubuntu 19.04) any attempt to update
grub seemed to fail as I could only boot to the existing kernel and not
to the newly installed kernel. I have seen this on more than one
occasion.

If this is an example of what you are reporting and something that has
been an issue since the 18.04 release then I can confirm the bug report.

There's a reference to my issue at:
https://ubuntuforums.org/showthread.php?t=2403574&p=13808168&viewfull=1#post13808168

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to grub2 in Ubuntu.
https://bugs.launchpad.net/bugs/1803805

Title:
  grub-pc fails to install on the last of multiple devices

Status in grub2 package in Ubuntu:
  New
Status in grub2 package in Debian:
  New

Bug description:
  When installing grub-pc to multiple devices, it fails installing on
  the last device. For the failing device, all of the errors show a
  stray comma at the end of the device name.

  This is occurring because install_devices is a multiselect, and the
  results are separated by commas. There is a comma at the end too. This
  ends up being interpreted as part of the device name. The package has
  code to remove the commas in the middle, but it does not remove the
  comma at the end.

  To reproduce this after the first failure, I had to do this (where that device is the _last_ device, on which the install is failing):
  grub-install /dev/disk/by-id/ata-ST4000NM0035-1V4107_ZC18GCZ3 && DEBCONF_DEBUG=developer dpkg-reconfigure grub-pc

  In the installed package's grub-pc.postinst, or the source package's debian/postinst.in, this is the code in question (indentation reduced 8 spaces):
      failed_devices=
      for i in `echo $RET | sed -e 's/, / /g'` ; do
        real_device="$(readlink -f "$i")"
        if grub-install --target=i386-pc --force --no-floppy $real_device ; then
          # We just installed GRUB 2; then also generate grub.cfg.
          touch /boot/grub/grub.cfg
        else
          failed_devices="$failed_devices $real_device"
        fi
      done

  For testing, I added a couple of echo statements:
       failed_devices=
  +    echo RET: $RET
       for i in `echo $RET | sed -e 's/, / /g'` ; do
         real_device="$(readlink -f "$i")"
  +      echo REAL: $real_device
         if grub-install --target=i386-pc --force --no-floppy $real_device ; then
           # We just installed GRUB 2; then also generate grub.cfg.
           touch /boot/grub/grub.cfg
         else
           failed_devices="$failed_devices $real_device"
         fi
       done

  This is the output:

  debconf (developer): <-- GET grub-pc/install_devices
  debconf (developer): --> 0 /dev/disk/by-id/ata-ST4000NM0035-1V4107_ZC18FT84, /dev/disk/by-id/ata-ST4000NM0035-1V4107_ZC18GPPQ, /dev/disk/by-id/ata-ST4000NM0035-1V4107_ZC18GCZ3,
  RET: /dev/disk/by-id/ata-ST4000NM0035-1V4107_ZC18FT84, /dev/disk/by-id/ata-ST4000NM0035-1V4107_ZC18GPPQ, /dev/disk/by-id/ata-ST4000NM0035-1V4107_ZC18GCZ3,
  REAL: /dev/sdb
  Installing for i386-pc platform.
  Installation finished. No error reported.
  REAL: /dev/sdc
  Installing for i386-pc platform.
  Installation finished. No error reported.
  REAL: /dev/disk/by-id/ata-ST4000NM0035-1V4107_ZC18GCZ3,
  Installing for i386-pc platform.
  grub-install: error: cannot find a GRUB drive for /dev/disk/by-id/ata-ST4000NM0035-1V4107_ZC18GCZ3,.  Check your device.map.
  debconf (developer): <-- SUBST grub-pc/install_devices_failed FAILED_DEVICES  /dev/disk/by-id/ata-ST4000NM0035-1V4107_ZC18GCZ3,

  The issue is definitely the comma at the end.

  To fix the issue, I changed the sed line to be like this:
      for i in `echo $RET | sed -e 's/,\( \|$\)/ /g'` ; do

  This strips the comma at the end, not just those in the middle (commas
  followed by spaces).

  Alternatively, if you prefer sed -E instead of backslashes for parens, this also works:
      for i in `echo $RET | sed -E 's/,( |$)/ /g'` ; do
  or if -e is important, this also works:
      for i in `echo $RET | sed -Ee 's/,( |$)/ /g'` ; do

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1803805/+subscriptions



More information about the foundations-bugs mailing list