Error unknown command hwmatch [closed]
Solution 1:
Dealing strictly with the hwmatch
problem look into /etc/grub.d/10_linux
and you will find it listed something like this near the bottom (9th line down on this display):
# 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
For whatever reason your grub installation is incomplete and missing hwmatch
module. You should see it among many other files when you use ll /boot/grub/i386-pc
:
-rw-r--r-- 1 root root 47292 Dec 5 07:13 hwmatch.mod
-rw-r--r-- 1 root root 2928 Dec 5 07:13 iorw.mod
-rw-r--r-- 1 root root 8656 Dec 5 07:13 iso9660.mod
-rw-r--r-- 1 root root 6168 Dec 5 07:13 jfs.mod
-rw-r--r-- 1 root root 6280 Dec 5 07:13 jpeg.mod
-rw-r--r-- 1 root root 5112 Dec 5 07:13 keylayouts.mod
-rw-r--r-- 1 root root 2044 Dec 5 07:13 keystatus.mod
-rw-r--r-- 1 root root 6608 Dec 5 07:13 ldm.mod
-rw-r--r-- 1 root root 29816 Dec 5 07:13 legacycfg.mod
-rw-r--r-- 1 root root 14536 Dec 5 07:13 legacy_password_test.mod
-rw-r--r-- 1 root root 8048 Dec 5 07:13 linux16.mod
-rw-r--r-- 1 root root 13184 Dec 5 07:13 linux.mod
-rw-r--r-- 1 root root 100 Dec 5 07:13 load.cfg
-rw-r--r-- 1 root root 5924 Dec 5 07:13 loadenv.mod
-rw-r--r-- 1 root root 3056 Dec 5 07:13 loopback.mod
-rw-r--r-- 1 root root 4872 Dec 5 07:13 lsacpi.mod
-rw-r--r-- 1 root root 2352 Dec 5 07:13 lsapm.mod
-rw-r--r-- 1 root root 1884 Dec 5 07:13 lsmmap.mod
-rw-r--r-- 1 root root 4136 Dec 5 07:13 ls.mod
-rw-r--r-- 1 root root 4928 Dec 5 07:13 lspci.mod
-rw-r--r-- 1 root root 6724 Dec 5 07:13 luks.mod
-rw-r--r-- 1 root root 6776 Dec 5 07:13 lvm.mod
As per this bug report (bugs.launchpad.net - Ubuntu Upgrade from Lucid to Precise results in broken grub configuration) the easiest way of getting all the grub modules is to reinstall it.
You should run
sudo dpkg-reconfigure grub-pc
and instruct it to install the boot loader somewhere, probably /dev/vda.
Above is a direct quote from the bug report. As a comment here points out and looking at your link, this should be used instead:
sudo dpkg-reconfigure grub-efi-amd64
However looking at this post (superuser.com - How to reinstall grub2 efi) you must first boot with a live USB/DVD and use:
sudo mount /dev/sda2 /mnt #sda2 is the root partition
sudo mount /dev/sda1 /mnt/boot/efi #sda1 is the efi partition
for i in /dev /dev/pts /proc /sys; do sudo mount -B $i /mnt$i; done
sudo cp /etc/resolv.conf /mnt/etc/ #makes the network available after chrooting
modprobe efivars # make sure this is loaded
sudo chroot /mnt
The first step is to confirm that the file hwmatch
is really missing. If so the easiest method is to simply copy it from:
/usr/lib/grub/i386-pc/hwmatch.mod
into the directory:
/boot/efi/efi/grub
This directory name comes from (https://help.ubuntu.com/community/UEFIBooting) where they say that is "mostly" the directory name. Please confirm for your installation.
The more complicated methods of dpkg-reconfigure
should be approached with extreme caution and only after appropriate backups.
Solution 2:
Did you try to use a different copy of your superblock (I think that 8193 and 32768 are examaples):
mke2fs -n /dev/XYZ
...
Superblock-Sicherungskopien gespeichert in den Blöcken:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, ...
Choose one copy of the superblock, e.g. the third one: In this case 163840
and do:
e2fsck -p -b 163840 /dev/XYZ
Solution 3:
For a Legacy boot, There's no reason you can't simply copy the spare file to the appropriate location as in sudo cp /usr/lib/grub/i386-pc/hwmatch.mod /boot/grub/i386-pc/hwmatch.mod
As my tests indicate that they are identical:
$ diff -s /usr/lib/grub/i386-pc/hwmatch.mod /boot/grub/i386-pc/hwmatch.mod
Files /usr/lib/grub/i386-pc/hwmatch.mod and /boot/grub/i386-pc/hwmatch.mod are identical
For EFI mode:
I've checked a fresh install of 16.04 in EFI mode and hwmatch.mod doesn't exist so i would assume it can be safely ignored. If it annoys you I would suggest backing up your current grub.cfg, searching your grub.cfg for the insmod hwmatch
line that's causing the issue and commenting it out to see if that alleviates the problem.