错误未知命令 hwmatch

ump*_*sky 7 boot grub2 raid

按照以下步骤安装 Ubuntu 16.04 后,每次启动时都会收到“未知命令 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
Run Code Online (Sandbox Code Playgroud)

当笔记本电脑电池耗尽或强制关机时,某些数据看起来会不一致。

还:

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 <device>
 or
    e2fsck -b 32768 <device>
Run Code Online (Sandbox Code Playgroud)

但是 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 <device>
 or
    e2fsck -b 32768 <device>
Run Code Online (Sandbox Code Playgroud)

谢谢。

评论中的注意事项:自从从 Clonezilla 备份恢复后,我无法重现此问题。

Win*_*nix 5

严格处理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
Run Code Online (Sandbox Code Playgroud)

无论出于何种原因,您的 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
Run Code Online (Sandbox Code Playgroud)

根据此错误报告(bugs.launchpad.net - Ubuntu Upgrade from Lucid to Precise results in bad grub configuration),获取所有 grub 模块的最简单方法是重新安装它。

您应该运行sudo dpkg-reconfigure grub-pc并指示它在某个位置安装引导加载程序,可能是 /dev/vda。

以上是错误报告的直接引用。正如这里的评论指出的那样,并查看您的链接,应该使用它:

sudo dpkg-reconfigure grub-efi-amd64
Run Code Online (Sandbox Code Playgroud)

然而,查看这篇文章(superuser.com - How to reinstall 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
Run Code Online (Sandbox Code Playgroud)

第一步是确认文件hwmatch确实丢失。如果是这样,最简单的方法就是简单地从以下位置复制它:

/usr/lib/grub/i386-pc/hwmatch.mod
Run Code Online (Sandbox Code Playgroud)

进入目录:

/boot/efi/efi/grub
Run Code Online (Sandbox Code Playgroud)

该目录名称来自(https://help.ubuntu.com/community/UEFIBooting),他们说这“主要”是目录名称。请确认您的安装。

dpkg-reconfigure极其谨慎地使用更复杂的方法,并且只有在进行适当的备份后才能使用。


mus*_*ach 2

您是否尝试使用超级块的不同副本(我认为 8193 和 32768 就是例子):

\n\n
mke2fs -n /dev/XYZ \n...\nSuperblock-Sicherungskopien gespeichert in den Bl\xc3\xb6cken:\n          32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, ...\n
Run Code Online (Sandbox Code Playgroud)\n\n

选择超级块的一个副本,例如第三个:在这种情况下163840执行以下操作:

\n\n
e2fsck -p -b 163840 /dev/XYZ\n
Run Code Online (Sandbox Code Playgroud)\n