grub issues message at boot - "error - can't find command hwmatch"

Solution 1:

To get rid of the error message, add this line to /etc/default/grub:

GRUB_GFXPAYLOAD_LINUX=keep

Source: #4 comment on https://bugs.launchpad.net/ubuntu/+source/grub2-signed/+bug/1840560

This will let a condition in the code get evaluated in such way that the codeblock referencing hwmatch gets bypassed.

As to how worrying is the missing command (or not): according to mook765's comment, it's part of only grub-pc, and not grub-efi, and is supposedly being referenced as a mistake in the case of a grub-efi install.

A voluntary remark on the countdown / menu:

Using

GRUB_TIMEOUT_STYLE=menu

instead of

GRUB_TIMEOUT_STYLE=countdown

would make the menu visible (while leaving the countdown feature (at the bottom of the screen) and automatic fallback selection intact).

Don't forget to run sudo update-grub after being done with the editing.

Solution 2:

I commented out the if-then structure in /etc/grub.d/10_linux that used hwmatch and that worked.

Note this was a Brute Force and Ignorance fix because I didn't know which of the outcomes in the if-then structure to choose. The one I chose worked for me, it may not for you.

After running sudo update-grub I got the desired result on boot.

# Use ELILO's generic "efifb" when it's known to be available.
# FIXME: We need an interface to select vesafb in case efifb can't be used.
if [ "x$GRUB_GFXPAYLOAD_LINUX" != x ] || [ "$gfxpayload_dynamic" = 0 ]; then
  echo "set linux_gfx_mode=$GRUB_GFXPAYLOAD_LINUX"
else
  cat << EOF
if [ "\${recordfail}" != 1 ]; then
  if [ -e \${prefix}/gfxblacklist.txt ]; then
#    if hwmatch \${prefix}/gfxblacklist.txt 3; then
#      if [ \${match} = 0 ]; then
        set linux_gfx_mode=keep
#      else
#        set linux_gfx_mode=text
#      fi
#    else
#      set linux_gfx_mode=text
#    fi
  else
    set linux_gfx_mode=keep
  fi
else
  set linux_gfx_mode=text
fi
EOF
fi
cat << EOF
export linux_gfx_mode
EOF

Note: at first this didn't work because I copied /etc/grub.d/10_linux to /etc/grub.d/10_linux-backup before editing it. But all executable files in grub.d get picked up so the original one got copied in too. I'm fortunate the system booted. I took the executable setting away from /etc/grub.d/10_linux-backup, re-ran sudo update-grub, and that did it.