Package: src:grub2
Version: 2.04-19
Tags: patch

When booting on x86_64 EFI this error message might be observed:

    error: can't find command `hwmatch'.

It's usually seen on a serial console; depending on settings
such as GRUB_TERMINAL=serial, GRUB_TIMEOUT_STYLE=hidden, and
/etc/grub.d/10_linux:gfxpayload_dynamic="1" (Ubuntu default),
and is easily reproducible with a KVM guest.

The issue seems to be that d/p/gfxpayload-dynamic.patch only
creates it in grub-core/commands/**i386/pc**/hwmatch.c, thus
it's not available in other grub platforms.

While it might be interesting to try and enable/fix that for
other platforms, it would be nice to have a trivial fix that
can more easily be considered to backport to stable releases.

Since hwmatch apparently never worked on non-i386/pc, simply
replacing the broken call with the equivalent behavior would
be sufficient.

That equivalent behavior is linux_gfx_mode=keep, despite the
error. This happens because in the error case the grub shell
evaluates `if hwmatch ...; then` to true and later evaluates
`if [ $match = 0 ]; then` to true as well, as it's undefined,
which does `set linux_gfx_mode=keep`.

The attached debdiff addresses the issue by checking for the
$grub_platform variable, and only calling hwmatch if that is
'pc', where hwmatch is available; otherwise, just use 'keep'
to keep the current behavior.

Before:

    error: can't find command `hwmatch'.
    ...

    grub> hwmatch
    error: can't find command `hwmatch'.

    grub> echo $grub_platform
    efi

    grub> echo $linux_gfx_mode
    keep

After:

    <no error message>
    ...

    grub> hwmatch
    error: can't find command `hwmatch'.

    grub> echo $grub_platform
    efi

    grub> echo $linux_gfx_mode
    keep

Tested on Bullseye RC2.

cheers,

-- 
Mauricio Faria de Oliveira

Attachment: grub2_hwmatch.debdiff
Description: Binary data

  • Bug#990836: grub2: fix "error: can't find ... Mauricio Faria de Oliveira

Reply via email to