[Bug 1840560] Re: "error: can't find command hwmatch" during grub

Mauricio Faria de Oliveira 1840560 at bugs.launchpad.net
Thu Jul 22 22:32:57 UTC 2021


** Description changed:

  [Impact]
  
-  * Users on non-pc/i386 platforms (e.g., efi/amd64) may observe
-    the message "error: can't find command `hwmatch'" every boot.
+  * Users on non-pc/i386 platforms (e.g., efi/amd64) may observe
+    the message "error: can't find command `hwmatch'" every boot.
  
-  * Also observed on cloud instances, generating support tickets
-    asking for clarification/impacts. (which could be deflected.)
+  * Also observed on cloud instances, generating support tickets
+    asking for clarification/impacts. (which could be deflected.)
  
-  * There' little or no impact, as hwmatch is only used to check
-    hardware device ID against a list for issues w/ graphics/KMS.
-    When this error happens, the default is set to keep graphics.
+  * There' little or no impact, as hwmatch is only used to check
+    hardware device ID against a list for issues w/ graphics/KMS.
+    When this error happens, the default is set to keep graphics.
  
-  * This has possibly always happened on non-pc/i386, as hwmatch
-    is patched/exists only in 'grub-core/commands/_i386/pc_' dir,
-    thus there doesn't seem to be any serious issues as a result.
+  * This has possibly always happened on non-pc/i386, as hwmatch
+    is patched/exists only in 'grub-core/commands/_i386/pc_' dir,
+    thus there doesn't seem to be any serious issues as a result.
  
  [Fix]
  
-  * Check for `$grub_platform != pc` then do not call hwmatch;
-    just keep current behavior (ie, keep graphics/framebuffer.)
+  * Check for `$grub_platform != pc` then do not call hwmatch;
+    just keep current behavior (ie, keep graphics/framebuffer.)
  
  [Test Plan]
  
-  * Boot a VM with EFI (e.g., multipass/libvirt/ovmf) and see
-    the serial console show the error message (or not, w/ fix.)
+  * Boot a VM with EFI (e.g., multipass/libvirt/ovmf) and see
+    the serial console show the error message (or not, w/ fix.)
  
- 	sudo snap install multipass
- 	sudo multipass set local.driver=libvirt
- 	sudo snap connect multipass:libvirt
+  sudo snap install multipass
+  sudo multipass set local.driver=libvirt
+  sudo snap connect multipass:libvirt
  
-         multipass launch -c 1 -d 4g -m 1g -n hwmatch-i daily:impish
+  multipass launch -c 1 -d 4g -m 1g -n hwmatch-i daily:impish
  
- 	sudo apt -y install ovmf
- 	sudo mkdir -p /var/lib/libvirt/qemu/nvram
+  sudo apt -y install ovmf
+  sudo mkdir -p /var/lib/libvirt/qemu/nvram
  
- 	virsh edit hwmatch-i
- 	  # insert in <os> section:
- 	  <loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
- 	  <nvram>/var/lib/libvirt/qemu/nvram/hwmatch-i.fd</nvram>
+  virsh edit hwmatch-i
+    # insert in <os> section:
+    <loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
+    <nvram>/var/lib/libvirt/qemu/nvram/hwmatch-i.fd</nvram>
  
- 	virsh shutdown hwmatch-i    
- 	virsh start --console hwmatch-i
- 	
-  * Before:
- 	...
- 	BdsDxe: loading Boot0003 "ubuntu" from ...\shimx64.efi
- 	BdsDxe: starting Boot0003 "ubuntu" from ...\shimx64.efi
- 	error: can't find command `hwmatch'.
- 	[    0.000000] Linux version ...
+  virsh shutdown hwmatch-i
+  virsh start --console hwmatch-i
  
-  * After:
- 	...
- 	BdsDxe: loading Boot0003 "ubuntu" from ...\shimx64.efi
- 	BdsDxe: starting Boot0003 "ubuntu" from ...\shimx64.efi
- 	[    0.000000] Linux version ...
-   
+  * Before:
+  ...
+  BdsDxe: loading Boot0003 "ubuntu" from ...\shimx64.efi
+  BdsDxe: starting Boot0003 "ubuntu" from ...\shimx64.efi
+  error: can't find command `hwmatch'.
+  [    0.000000] Linux version ...
+ 
+  * After: (installing grub-common_*.deb is enough to test.)
+  ...
+  BdsDxe: loading Boot0003 "ubuntu" from ...\shimx64.efi
+  BdsDxe: starting Boot0003 "ubuntu" from ...\shimx64.efi
+  [    0.000000] Linux version ...
+ 
  [Where problems could occur]
  
-  * Issues with graphics/flickering during boot on systems with
-    graphics adapters in use might be hit in case of regression.
-    
-  * Theoretically the risk is low, since hwmatch apparently has
-    never worked on non-pc/i386, and we replace the broken call
-    while keeping current behavior observed with it ("no change".)
+  * Issues with graphics/flickering during boot on systems with
+    graphics adapters in use might be hit in case of regression.
+ 
+  * Theoretically the risk is low, since hwmatch apparently has
+    never worked on non-pc/i386, and we replace the broken call
+    while keeping current behavior observed with it ("no change".)
  
  [Other Info]
-  
-  * While it might be interesting to try and enable/fix it for
-    other platforms, let's have a trivial fix to be considered
-    to backport to stable releases, at this time (less changes.)
  
-  * The same behavior is linux_gfx_mode=keep, despite the error.
-    This happens because in the error case, grub shell evaluates
-    if hwmatch ...; then` to true, and `if [ $match = 0 ]; then`
-    to true too (as it's undefined) so `set linux_gfx_mode=keep`.
+  * While it might be interesting to try and enable/fix it for
+    other platforms, let's have a trivial fix to be considered
+    to backport to stable releases, at this time (less changes.)
  
-    Before/After in grub shell (same behavior):
-    
-     grub> hwmatch
-     error: can't find command `hwmatch'.
+  * The same behavior is linux_gfx_mode=keep, despite the error.
+    This happens because in the error case, grub shell evaluates
+    if hwmatch ...; then` to true, and `if [ $match = 0 ]; then`
+    to true too (as it's undefined) so `set linux_gfx_mode=keep`.
  
-     grub> echo $grub_platform
-     efi
+    Before/After in grub shell (same behavior):
  
-     grub> echo $linux_gfx_mode
-     keep
+     grub> hwmatch
+     error: can't find command `hwmatch'.
  
-  * Other details in Debian bug 990836 [1].
-  
-  * It looks like grub2-unsigned follows grub2 automatically,
-    so not providing debdiffs to it/just grub2.
+     grub> echo $grub_platform
+     efi
+ 
+     grub> echo $linux_gfx_mode
+     keep
+ 
+  * Other details in Debian bug 990836 [1].
+ 
+  * It looks like grub2-unsigned follows grub2 automatically,
+    so not providing debdiffs to it/just grub2.
  
  [Links]
-  * [1] https://bugs.debian.org/990836
-  
+  * [1] https://bugs.debian.org/990836
+ 
  [Original Description]
  Upon disabling my grub menu using grub-customizer, I've noticed that just before the system boots and goes into the crypto password prompt the following error message appears on the display:
  
  ```
  error: can't find command hwmatch
  ```
  
  Looks like this command is referenced from /boot/grub/grub/cfg
  
  ```
      if hwmatch ${prefix}/gfxblacklist.txt 3; then
  ```
  However, the mod doesn't exist on grub's mod folder:
  
  ```
  ~ ls -la /boot/grub/x86_64-efi/*.mod|wc -l
  269
  
  ~ ls -la /boot/grub/x86_64-efi/hw*
  fish: No matches for wildcard “/boot/grub/x86_64-efi/hw*”
  
  ```
  
  ProblemType: Bug
  DistroRelease: Ubuntu 19.04
  Package: grub-efi-amd64-signed 1.115+2.02+dfsg1-12ubuntu2
  ProcVersionSignature: Ubuntu 5.0.0-25.26-generic 5.0.18
  Uname: Linux 5.0.0-25-generic x86_64
  ApportVersion: 2.20.10-0ubuntu27.1
  Architecture: amd64
  CurrentDesktop: Unity
  Date: Sun Aug 18 00:22:41 2019
  InstallationDate: Installed on 2019-08-17 (0 days ago)
  InstallationMedia: Ubuntu 19.04 "Disco Dingo" - Release amd64 (20190416)
  SourcePackage: grub2-signed
  UpgradeStatus: No upgrade log present (probably fresh install)

** Description changed:

  [Impact]
  
   * Users on non-pc/i386 platforms (e.g., efi/amd64) may observe
     the message "error: can't find command `hwmatch'" every boot.
  
   * Also observed on cloud instances, generating support tickets
     asking for clarification/impacts. (which could be deflected.)
  
   * There' little or no impact, as hwmatch is only used to check
     hardware device ID against a list for issues w/ graphics/KMS.
     When this error happens, the default is set to keep graphics.
  
   * This has possibly always happened on non-pc/i386, as hwmatch
     is patched/exists only in 'grub-core/commands/_i386/pc_' dir,
     thus there doesn't seem to be any serious issues as a result.
  
  [Fix]
  
   * Check for `$grub_platform != pc` then do not call hwmatch;
     just keep current behavior (ie, keep graphics/framebuffer.)
  
  [Test Plan]
  
   * Boot a VM with EFI (e.g., multipass/libvirt/ovmf) and see
     the serial console show the error message (or not, w/ fix.)
  
   sudo snap install multipass
   sudo multipass set local.driver=libvirt
   sudo snap connect multipass:libvirt
  
   multipass launch -c 1 -d 4g -m 1g -n hwmatch-i daily:impish
  
   sudo apt -y install ovmf
   sudo mkdir -p /var/lib/libvirt/qemu/nvram
  
   virsh edit hwmatch-i
     # insert in <os> section:
     <loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
     <nvram>/var/lib/libvirt/qemu/nvram/hwmatch-i.fd</nvram>
  
   virsh shutdown hwmatch-i
   virsh start --console hwmatch-i
  
   * Before:
   ...
   BdsDxe: loading Boot0003 "ubuntu" from ...\shimx64.efi
   BdsDxe: starting Boot0003 "ubuntu" from ...\shimx64.efi
   error: can't find command `hwmatch'.
   [    0.000000] Linux version ...
  
-  * After: (installing grub-common_*.deb is enough to test.)
+  * After:
+  sudo dpkg -i grub_common_*.deb # test package; g-c is enough.
+  sudo update-grub && sudo reboot
   ...
   BdsDxe: loading Boot0003 "ubuntu" from ...\shimx64.efi
   BdsDxe: starting Boot0003 "ubuntu" from ...\shimx64.efi
   [    0.000000] Linux version ...
  
  [Where problems could occur]
  
   * Issues with graphics/flickering during boot on systems with
     graphics adapters in use might be hit in case of regression.
  
   * Theoretically the risk is low, since hwmatch apparently has
     never worked on non-pc/i386, and we replace the broken call
     while keeping current behavior observed with it ("no change".)
  
  [Other Info]
  
   * While it might be interesting to try and enable/fix it for
     other platforms, let's have a trivial fix to be considered
     to backport to stable releases, at this time (less changes.)
  
   * The same behavior is linux_gfx_mode=keep, despite the error.
     This happens because in the error case, grub shell evaluates
     if hwmatch ...; then` to true, and `if [ $match = 0 ]; then`
     to true too (as it's undefined) so `set linux_gfx_mode=keep`.
  
     Before/After in grub shell (same behavior):
  
      grub> hwmatch
      error: can't find command `hwmatch'.
  
      grub> echo $grub_platform
      efi
  
      grub> echo $linux_gfx_mode
      keep
  
   * Other details in Debian bug 990836 [1].
  
   * It looks like grub2-unsigned follows grub2 automatically,
     so not providing debdiffs to it/just grub2.
  
  [Links]
   * [1] https://bugs.debian.org/990836
  
  [Original Description]
  Upon disabling my grub menu using grub-customizer, I've noticed that just before the system boots and goes into the crypto password prompt the following error message appears on the display:
  
  ```
  error: can't find command hwmatch
  ```
  
  Looks like this command is referenced from /boot/grub/grub/cfg
  
  ```
      if hwmatch ${prefix}/gfxblacklist.txt 3; then
  ```
  However, the mod doesn't exist on grub's mod folder:
  
  ```
  ~ ls -la /boot/grub/x86_64-efi/*.mod|wc -l
  269
  
  ~ ls -la /boot/grub/x86_64-efi/hw*
  fish: No matches for wildcard “/boot/grub/x86_64-efi/hw*”
  
  ```
  
  ProblemType: Bug
  DistroRelease: Ubuntu 19.04
  Package: grub-efi-amd64-signed 1.115+2.02+dfsg1-12ubuntu2
  ProcVersionSignature: Ubuntu 5.0.0-25.26-generic 5.0.18
  Uname: Linux 5.0.0-25-generic x86_64
  ApportVersion: 2.20.10-0ubuntu27.1
  Architecture: amd64
  CurrentDesktop: Unity
  Date: Sun Aug 18 00:22:41 2019
  InstallationDate: Installed on 2019-08-17 (0 days ago)
  InstallationMedia: Ubuntu 19.04 "Disco Dingo" - Release amd64 (20190416)
  SourcePackage: grub2-signed
  UpgradeStatus: No upgrade log present (probably fresh install)

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to grub2 in Ubuntu.
https://bugs.launchpad.net/bugs/1840560

Title:
  "error: can't find command hwmatch" during grub

Status in grub2 package in Ubuntu:
  In Progress
Status in grub2-signed package in Ubuntu:
  Invalid
Status in grub2 source package in Focal:
  In Progress
Status in grub2-signed source package in Focal:
  Invalid
Status in grub2 source package in Groovy:
  Invalid
Status in grub2-signed source package in Groovy:
  Invalid
Status in grub2 source package in Hirsute:
  In Progress
Status in grub2-signed source package in Hirsute:
  Invalid
Status in grub2 source package in Impish:
  In Progress
Status in grub2-signed source package in Impish:
  Invalid
Status in grub2 package in Debian:
  New

Bug description:
  [Impact]

   * Users on non-pc/i386 platforms (e.g., efi/amd64) may observe
     the message "error: can't find command `hwmatch'" every boot.

   * Also observed on cloud instances, generating support tickets
     asking for clarification/impacts. (which could be deflected.)

   * There' little or no impact, as hwmatch is only used to check
     hardware device ID against a list for issues w/ graphics/KMS.
     When this error happens, the default is set to keep graphics.

   * This has possibly always happened on non-pc/i386, as hwmatch
     is patched/exists only in 'grub-core/commands/_i386/pc_' dir,
     thus there doesn't seem to be any serious issues as a result.

  [Fix]

   * Check for `$grub_platform != pc` then do not call hwmatch;
     just keep current behavior (ie, keep graphics/framebuffer.)

  [Test Plan]

   * Boot a VM with EFI (e.g., multipass/libvirt/ovmf) and see
     the serial console show the error message (or not, w/ fix.)

   sudo snap install multipass
   sudo multipass set local.driver=libvirt
   sudo snap connect multipass:libvirt

   multipass launch -c 1 -d 4g -m 1g -n hwmatch-i daily:impish

   sudo apt -y install ovmf
   sudo mkdir -p /var/lib/libvirt/qemu/nvram

   virsh edit hwmatch-i
     # insert in <os> section:
     <loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
     <nvram>/var/lib/libvirt/qemu/nvram/hwmatch-i.fd</nvram>

   virsh shutdown hwmatch-i
   virsh start --console hwmatch-i

   * Before:
   ...
   BdsDxe: loading Boot0003 "ubuntu" from ...\shimx64.efi
   BdsDxe: starting Boot0003 "ubuntu" from ...\shimx64.efi
   error: can't find command `hwmatch'.
   [    0.000000] Linux version ...

   * After:
   sudo dpkg -i grub_common_*.deb # test package; g-c is enough.
   sudo update-grub && sudo reboot
   ...
   BdsDxe: loading Boot0003 "ubuntu" from ...\shimx64.efi
   BdsDxe: starting Boot0003 "ubuntu" from ...\shimx64.efi
   [    0.000000] Linux version ...

  [Where problems could occur]

   * Issues with graphics/flickering during boot on systems with
     graphics adapters in use might be hit in case of regression.

   * Theoretically the risk is low, since hwmatch apparently has
     never worked on non-pc/i386, and we replace the broken call
     while keeping current behavior observed with it ("no change".)

  [Other Info]

   * While it might be interesting to try and enable/fix it for
     other platforms, let's have a trivial fix to be considered
     to backport to stable releases, at this time (less changes.)

   * The same behavior is linux_gfx_mode=keep, despite the error.
     This happens because in the error case, grub shell evaluates
     if hwmatch ...; then` to true, and `if [ $match = 0 ]; then`
     to true too (as it's undefined) so `set linux_gfx_mode=keep`.

     Before/After in grub shell (same behavior):

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

      grub> echo $grub_platform
      efi

      grub> echo $linux_gfx_mode
      keep

   * Other details in Debian bug 990836 [1].

   * It looks like grub2-unsigned follows grub2 automatically,
     so not providing debdiffs to it/just grub2.

  [Links]
   * [1] https://bugs.debian.org/990836

  [Original Description]
  Upon disabling my grub menu using grub-customizer, I've noticed that just before the system boots and goes into the crypto password prompt the following error message appears on the display:

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

  Looks like this command is referenced from /boot/grub/grub/cfg

  ```
      if hwmatch ${prefix}/gfxblacklist.txt 3; then
  ```
  However, the mod doesn't exist on grub's mod folder:

  ```
  ~ ls -la /boot/grub/x86_64-efi/*.mod|wc -l
  269

  ~ ls -la /boot/grub/x86_64-efi/hw*
  fish: No matches for wildcard “/boot/grub/x86_64-efi/hw*”

  ```

  ProblemType: Bug
  DistroRelease: Ubuntu 19.04
  Package: grub-efi-amd64-signed 1.115+2.02+dfsg1-12ubuntu2
  ProcVersionSignature: Ubuntu 5.0.0-25.26-generic 5.0.18
  Uname: Linux 5.0.0-25-generic x86_64
  ApportVersion: 2.20.10-0ubuntu27.1
  Architecture: amd64
  CurrentDesktop: Unity
  Date: Sun Aug 18 00:22:41 2019
  InstallationDate: Installed on 2019-08-17 (0 days ago)
  InstallationMedia: Ubuntu 19.04 "Disco Dingo" - Release amd64 (20190416)
  SourcePackage: grub2-signed
  UpgradeStatus: No upgrade log present (probably fresh install)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1840560/+subscriptions




More information about the foundations-bugs mailing list