41

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?

2
  • 2
    I do not use nor really know RAID, but you install grub to the root of the RAID not to the MBR of a drive. If you run Boot-Repair you then might get a message like this. No boot loader is installed in the MBR of /dev/mapper/isw_cdjacjeebj_VOLUME_0. Where the mapper is your RAID volume.
    – oldfred
    Apr 11, 2014 at 4:07

2 Answers 2

32
+50

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
8
  • 3
    Is this a reliable test for grub2 installations? Also, keyboard input doesn't seem to work for the menu that appears; is there a trick for enabling it? Apr 26, 2019 at 21:35
  • 4
    I cant close grub-emu, only way to stop it is pkill -SIGKILL -fe grub-emu, keyboard input not working either May 2, 2019 at 16:08
  • 4
    @MichaelScheper this fixes the interactiveness serverfault.com/a/847429/163750 :). Basically, xterm -e grub-emu and keep the focus on xterm not the grub-emu window! May 2, 2019 at 16:17
  • 1
    @Tschallacka for me that also does not work, emulator does not react on any inputs at all. Oct 4, 2020 at 12:07
  • 2
    You have to set focus to the termial in which you started the emulator to be able to do inputs! The window of the emulator self will not react to any inputs at all. Oct 4, 2020 at 12:36
6

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.

2
  • 2
    That answer only uses file -s for grub1, for grub 2 there is a second answer suggesting dd bs=512 count=1 if=/dev/sda 2>/dev/null | strings|grep GRUB
    – rubo77
    Oct 15, 2015 at 19:52
  • 1
    there is no "/boot/grub/device.map", but thx for that link ! May 2, 2019 at 16:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .