错误未知命令 hwmatch

分享于 

7分钟阅读

ubuntu

  繁體

问题

apt-get install -y grub-efi-amd64

系统正可以常启动,但我想修复这个错误,有没有办法更新配置并修复它?

我启动了live 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 <device>


 or


 e2fsck -b 32768 <device>



但是efsck无法修复它:


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>




答案1

查看/etc/grub.d/10_linux,你会发现它在底部(此显示器的第八行)附近列出类似这样的内容:


# 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



根据这个bug报告,(yf砦u1-yf砦u2从yf砦u3到yf砦u4导致幼虫形态破坏)获取所有grub模块的最简单方法是重新安装它。

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

上面的错误报告直接引用,作为评论这里指出和查看你的链接,这应该使用:


sudo dpkg-reconfigure grub-efi-amd64



您必须首先使用实时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




答案2


mke2fs -n /dev/XYZ 


...


Superblock-Sicherungskopien gespeichert in den Blöcken:


 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, ...



选择超级块的一个副本,例如第三个副本:在这种情况下,163840和do:


e2fsck -p -b 163840 /dev/XYZ




答案3

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




COM  COMM  BOO  引导  Comma