是否可以在不重新启动的情况下validationgrub安装?

我已经被这么多次咬过了,今天在我的服务器grub中的openssl更新后抱怨我应该再次安装它,因为“以前安装的硬盘不存在”。

我有一个raid 1安装,具有以下设置(根据bootinfoscript):

 > ============================= Boot Info Summary: =============================== > > => Grub2 (v1.99) is installed in the MBR of /dev/sda and looks at > sector 1 of the same hard drive for core.img. core.img is at this location and looks > for (mduuid/d2a04f98760e2b3cc23ba87845667605)/grub on this drive. > > => Grub2 (v1.99) is installed in the MBR of /dev/sdb and looks at sector 1 of > the same hard drive for core.img. core.img is at this location and looks > for (mduuid/d2a04f98760e2b3cc23ba87845667605)/grub on this drive. My mount points are: > /dev/md2 on / type ext4 (rw) > /dev/md1 on /boot type ext3 (rw) And mduuid seems to match the ones bootinfoscript mentions: > ls -l /dev/disk/by-id/md-uuid-* > > lrwxrwxrwx 1 root root 9 Mar 19 11:37 /dev/disk/by-id/md-uuid-38048286:e3004e47:510ca3e1:2bae3f2e -> ../../md2 > > lrwxrwxrwx 1 root root 9 Mar 19 11:37 /dev/disk/by-id/md-uuid-d2a04f98:760e2b3c:c23ba878:45667605 -> ../../md1 > > lrwxrwxrwx 1 root root 9 Mar 19 11:37 /dev/disk/by-id/md-uuid-e099b695:0143bb58:e4ef7645:0f22ce0b -> ../../md0 

运行grub-install有效,但我想确保重启grub后实际上会正确启动我的分区。

我该如何validation?

我不认为您可以在尝试之前检查这是否有效,但您可以立即预览GRUB,以确保您的新配置在GRUB中正确加载。

这可以使用名为grub-emu的工具来实现。

man grub-emu

 NAME grub-emu - GRUB emulator SYNOPSIS grub-emu [OPTION]... DESCRIPTION GRUB emulator. -r, --root-device=DEV use DEV as the root device [default=guessed] -m, --device-map=FILE use FILE as the device map [default=/boot/grub/device.map] -d, --directory=DIR use GRUB files in the directory DIR [default=/boot/grub] -v, --verbose print verbose messages 

使用命令行轻松安装grub-emu

 sudo apt-get install grub-emu 

要运行它,只需使用terminal运行此命令:

 grub-emu 

这个答案使用file -s /dev/sda来查看GRUB MBR是否已成功安装。 过去,你绝对可以仔细检查/boot/grub/grub.cfg的值,以确保UUID与/dev/disk/by-uuid的值匹配,并确保/boot/grub/device.map所有内容都正确/boot/grub/device.map 。 如果该文件错误,您将无法使用grub.cfg中的(hdX)规范。

如果您在替换驱动器上安装grub后使用update-grub ,则无需手动管理这些文件。 根据我的经验,最大的问题是没有更新GRUB配置,没有在所有驱动器上安装GRUB,或者不正确的分区使得它不能在不使用–force的情况下安装GRUB。