错误未知命令hwmatch
我按照以下步骤安装Ubuntu 16.04后,在每次启动时收到“unknown command hwmatch”消息: https ://gist.github.com/umpirsky/6ee1f870e759815333c8以设置RAID0。
特别注意apt-get install -y grub-efi-amd64
部分https://gist.github.com/umpirsky/6ee1f870e759815333c8#file-ubuntu-raid-sh-L40
由于某种原因,我无法使用apt-get,所以我手动安装下载deb并使用dpkg -i。
有一个与此错误相关的错误报告https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/733836 。
系统正常启动,但我想修复此错误。 有没有办法更新配置并修复它?
更新:使用系统一个月后,有一天它只是无法启动此错误,最终在initramfs提示符中,我从clonezilla备份恢复它,但我担心它会再次发生。 最糟糕的是,我不知道为什么会这样。
更新:
它再次发生,并且经常在强制关闭或用完batterx之后发生。 我启动了现场USB并运行fsck:
sudo fsck /dev/sda1 fsck from util-linux 2.20.1 fsck.fat 3.0.26 (2014-03-07) 0x41: Dirty bit is set. Fs was not properly unmounted and some data may be corrupt. 1) Remove dirty bit 2) No action ? 2 There are differences between boot sector and its backup. This is mostly harmless. Differences: (offset:original/backup) 65:01/00 1) Copy original to backup 2) Copy backup to original 3) No action
当笔记本电脑电量耗尽或强制关机时,看起来有些数据不一致。
也:
sudo fsck /dev/md0 fsck from util-linux 2.20.1 e2fsck 1.42.9 (4-Feb-2014) ext2fs_open2: Bad magic number in super-block fsck.ext2: Superblock invalid, trying backup blocks... fsck.ext2: Bad magic number in super-block while trying to open /dev/md0 The superblock could not be read or does not describe a valid ext2/ext3/ext4 filesystem. If the device is valid and it really contains an ext2/ext3/ext4 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock: e2fsck -b 8193 or e2fsck -b 32768
但是e2fsck没有修复它:
sudo e2fsck -b 8193 /dev/md0 e2fsck 1.42.9 (4-Feb-2014) e2fsck: Bad magic number in super-block while trying to open /dev/md0 The superblock could not be read or does not describe a valid ext2/ext3/ext4 filesystem. If the device is valid and it really contains an ext2/ext3/ext4 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock: e2fsck -b 8193 or e2fsck -b 32768
谢谢。
评论提示:自从Clonezilla备份恢复后,我无法重现这一点。
严格按照hwmatch
问题处理/etc/grub.d/10_linux
,你会发现它在底部附近列出了这样的东西(显示屏上的第9行):
# 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
无论出于何种原因,您的grub安装不完整且缺少hwmatch
模块。 当你使用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
根据这个错误报告( bugs.launchpad.net - Ubuntu从Lucid升级到精确导致grub配置损坏 )获取所有grub模块的最简单方法是重新安装它。
您应该运行
sudo dpkg-reconfigure grub-pc
并指示它在某处安装引导加载程序,可能是/ dev / vda。
以上是错误报告的直接引用。 这里的评论指出并查看您的链接,应该使用它:
sudo dpkg-reconfigure grub-efi-amd64
无论如何看这篇文章( superuser.com - 如何重新安装grub2 efi ),你必须先用现场USB / DVD启动并使用:
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
第一步是确认文件hwmatch
确实丢失了。 如果是这样,最简单的方法是简单地从以下位置复制它:
/usr/lib/grub/i386-pc/hwmatch.mod
进入目录:
/boot/efi/efi/grub
此目录名称来自( https://help.ubuntu.com/community/UEFIBooting ),他们说这是“主要”目录名称。 请确认您的安装。
应该非常谨慎地处理更复杂的dpkg-reconfigure
方法,并且只能在适当的备份之后进行。
您是否尝试使用超级块的不同副本(我认为8193和32768是examaples):
mke2fs -n /dev/XYZ ... Superblock-Sicherungskopien gespeichert in den Blöcken: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, ...
选择超级块的一个副本,例如第三个:在这种情况下163840
并执行:
e2fsck -p -b 163840 /dev/XYZ
对于Legacy启动 ,没有理由不能像在sudo cp /usr/lib/grub/i386-pc/hwmatch.mod /boot/grub/i386-pc/hwmatch.mod
那样简单地将备用文件复制到适当的位置sudo cp /usr/lib/grub/i386-pc/hwmatch.mod /boot/grub/i386-pc/hwmatch.mod
正如我的测试表明它们是相同的:
$ 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
对于EFI模式:
我在EFI模式下检查了16.04的全新安装,并且hwmatch.mod不存在,所以我认为可以安全地忽略它。 如果它让你烦恼,我会建议你备份你当前的grub.cfg,在你的grub.cfg中搜索导致问题的insmod hwmatch
行并将其评论出去以查看是否可以缓解问题。