How can I discover which bootloader is installed where?

On a Debian Linux box, I'm running into a very strange situation where after power-on, GRUB fails with the error "no such partition", but if I then hit the reset button, it boots normally. I'm trying to diagnose the situation, and I realized that I don't know which versions of what bootloaders are installed where? How can I find out? That is, how can I find out what bootloader is installed on the MBR of each of my disks, and how can I find out which second-stage bootloaders are installed on the various partitions?

If I can't find out exactly what I have, I'd settle for being able to find out just which version of GRUB is installed where.


Solution 1:

You can see whether GRUB (1 or 2) is installed on the MBR with dd:

dd if=/dev/sda bs=512 count=1 2> /dev/null | grep -q GRUB && echo "GRUB found"

If GRUB signature was found you can then run:

file -s /dev/sda

If the output is something like:

/dev/sda: x86 boot sector; GRand Unified Bootloader, stage1 version 0x3...........

then you have GRUB1 installed on the MBR. If there is no mention of Grub, like this:

/dev/sda: x86 boot sector; partition 1: ID=0x83, active, starthead 32, startsector 2048........

then you have GRUB2 installed on the MBR of that disk.

To find the essential GRUB files ("stages" for GRUB1, "images" for GRUB2):

GRUB1:

configuration file:

find / -name menu.lst

stages:

find / -name stage1

or

find / -name stage2

GRUB2:

configuration file:

find / -name grub.cfg

images:

find / -name core.img

or

find / -name boot.img

Solution 2:

You can use http://bootinfoscript.sourceforge.net which gives you detailed information about your boot status and tells you which bootloader is installed where, combined with lots of detailed other information relevant to booting. It's available in debian as package boot-info-script.