8

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.

3
  • Have you pressed the "Esc" key (to display Grub's boot menu) before the error message appears?
    – sawdust
    Aug 25, 2012 at 1:45
  • @sawdust we don't get as far as a menu. Just "Grub loading; Welcome to Grub;" and then the error. Normally I would expect a menu and then autoboot after a timeout of 10s. But I'm not getting that far. Hence the question about "how do I figure out what is there." Maybe my job is just to reinstall everything :-( Aug 25, 2012 at 1:48

2 Answers 2

14

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 a 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 isn’t any mention of GRUB, like this:

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

then you have GRUB 2 installed on the MBR of that disk.

To find the essential GRUB files ("stages" for GRUB 1, "images" for GRUB 2):

GRUB 1:

Configuration file:

find / -name menu.lst

Stages:

find / -name stage1

or

find / -name stage2

GRUB 2:

Configuration file:

find / -name grub.cfg

Images:

find / -name core.img

or

find / -name boot.img
4
  • 1
    Absolutely brilliant. It seems file(1) has everything these days. Aug 25, 2012 at 22:49
  • Using file -s helped me find the Windows bootloader on my PC. Thanks!
    – wjandrea
    Mar 8, 2017 at 20:58
  • What is the gist of the dd command? Examine the first 512 bytes of the device? Mar 11, 2023 at 11:40
  • This could be updated for UEFI / GPT partitioning. But ********* ********* without ********* ********* "Edit:", "Update:", or similar - the answer should appear as if it was written today) Mar 11, 2023 at 11:42
6

You can use Boot Info Script 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.

1
  • 2
    sudo apt install boot-info-script and then sudo bootinfoscript. The output is in RESULTS.txt. Valid on Ubuntu 18.04 (5 years later).
    – estibordo
    Apr 29, 2018 at 13:43

You must log in to answer this question.

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