5

This question Error unknown command hwmatch is exactly what I'm asking but was closed as non reproducible. Mine is very reproducible.

Ubuntu 18.04 freshly installed on a 64-bit UEFI machine. Default grub boot options work fine, but I wanted to add a brief countdown (my normal config). After editing /etc/default/grub as normal and running sudo update-grub, the countdown works, but I get the error shown in the question title.

I tried the solution (copying files) in the closed question but it didn't seem to fit my configuration. Frankly I found the answer confusing.

I also tried editing /etc/grub.d/10_linux to comment out the IF-THEN structure that uses hwmatch. After that I did a sudo update-grub but I still got the error.

How can I get my countdown and not see this error?

Edit per comments -

Stock grub as installed (all non-commented-out lines shown)

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

Edited grub to give countdown (all non-commented-out lines shown)

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=countdown
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
16
  • Edit your question and show us cat /etc/default/grub. Tell me what you edited/added to enable countdown. – heynnema Sep 15 '19 at 20:17
  • Did you ever add an "insmod hwmatch" anywhere in the grub.d files? – ubfan1 Sep 15 '19 at 20:46
  • @ubfan1 No, I didn't. Please elaborate. – Organic Marble Sep 15 '19 at 20:46
  • @OrganicMarble show me the other grub lines that are not commented out. – heynnema Sep 15 '19 at 20:57
  • hwmatch.mod is a module in the /boot/grub/i386-pc directory, and may need an explicit insmod somewhere before the use of hwmatch command in 10_linux. Pick a location in the executation path (not in a function) before the hwmatch command to add insmod hwmatch.. – ubfan1 Sep 15 '19 at 20:59
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.

2

1. to get rid of the error message:

Instead of commenting out the code, like in the accepted answer, one could 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

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

2. to display the grub menu:

Instead of

GRUB_TIMEOUT_STYLE=countdown

use

GRUB_TIMEOUT_STYLE=menu

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.