Bug#990836: grub2: fix "error: can't find command `hwmatch'." on efi-amd64
Mauricio Faria de Oliveira
mfo at canonical.com
Fri Jul 9 00:26:07 BST 2021
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: grub2_hwmatch.debdiff
Type: application/octet-stream
Size: 2244 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-grub-devel/attachments/20210708/885b897f/attachment.obj>
More information about the Pkg-grub-devel
mailing list