update-grub outputs spurious error messages on systems with lvm

Bug #1990035 reported by mike
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
grub2 (Ubuntu)
New
Undecided
Unassigned
os-prober (Ubuntu)
Triaged
Low
Unassigned

Bug Description

There are 4 instances of spurious error messages (that I have found) 2 in grub-common and 2 in os-prober in 22.04.1 (and I am sure many older releases)

1) /usr/share/os-prober/common.sh
This will output an error if there is a non-active LVM partition.

In function fs_type (line 108) the call to lsblk (line 116) is not guarded by "2>/dev/null" and spuriously outputs
lsblk: /dev/mapper/VG-LV: not a block device

2) /usr/lib/os-probes/50mounted-tests
Outputs a error for any filesystem that grub can't read, but the native OS can.

At line 65 the call to grub-probe is not guarded by "2>/dev/null" and spuriously outputs
grub-probe: error: disk `lvmid/X7waXv-rMDA-5fQA-aw6l-ei1I-8Gz3-pQl3lr/DEqUcG-PfhJ-zOes-gvvA-jgdh-f8g5-8YktOE' not found.
for each active thin partition it finds. I did not test it with other file systems

3) /etc/grub.d/30_os-prober
outputs a spurious error if when looking for a UUID for a root partition that grub can't mount, but the native OS can (and hopefully the target OS can).

  if UUID="`${grub_probe} --target=fs_uuid --device ${DEVICE%@*}`"; then (line 144)
the call to grub-probe needs to be guarded by "2>/dev/null"

4) /etc/grub.d/30_os-prober - /usr/share/grub/grub-mkconfig_lib
Function prepare_grub_to_access_device (line 121 of grub-mkconfig_lib) doesn't check if the device is mountable/readable by grub. It is called by /etc/grub.d/30_os-prober (line 268).
This only happens if a Linux system partition points to a boot partition that is not readable by GRUB and so is already invalid. One could argue all bets are off, but ....

Perhaps something like the following could be added

        if [ x"`${grub_probe} --target=partmap --device "${LBOOT}" 2>/dev/null`" = x ] ; then
          gettext_printf "boot partition "%s" is not readable by GRUB\n" "${LBOOT}" >&2
          continue
        fi
around line 258 in /etc/grub.d/30_os-prober and avoid the call to prepare_grub_to_access_device. This may give the user have half a chance of figuring out what they did wrong.

Changed in os-prober (Ubuntu):
status: New → Triaged
importance: Undecided → Low
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.