Is it possible to verify grub installation without rebooting?
I've been bitten by this so many times, and today after the openssl
updates in my server grub complained that I should install it again since the "hard disks that it was previously installed do not exist".
I have a raid 1 installation with the following setup (according to 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
Running grub-install works, but I want to make sure that after rebooting grub will actually correctly boot up my partitions.
How can I verify it?
Solution 1:
I don't think you can just check whether this will works or not before trying to do it, but instead you can get a preview of your GRUB instantly so you can be sure that your new configuration is loaded correctly in GRUB.
This could be achieved using a tool called 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
Easily install grub-emu
using command line:
sudo apt-get install grub-emu
To run it just use terminal to run this command:
grub-emu
Solution 2:
This answer uses file -s /dev/sda
to see if the GRUB MBR has been successfully installed. Past that, you could definitely double-check the values in /boot/grub/grub.cfg
to make sure the UUIDs match up with the values in /dev/disk/by-uuid
, and make sure that everything looks right in /boot/grub/device.map
. If that file is wrong you'll have trouble with (hdX) specifications in grub.cfg.
Managing these files manually isn't necessary though if you're using update-grub
after installing grub on replacement drives. The biggest gotchas in my experience have been not updating the GRUB configuration, not installing GRUB on all the drives, or improper partitioning that makes it so you can't install GRUB without using --force.