Boot Loaders, Boot Sectors, BIOS, and GRUB

Again, I must apologize if this is "easily googlable". I have tried.

My understanding is that the BIOS typically looks for the magic number 0x55aa at the end of a 512 byte sector (so bytes #511 and #512). Once it finds that, it begins executing that code. That code can then load the operating system. It finds this by checking all bootable disks/drives until it finds that sector, right?

I wrote a simple boot sector, and verified this mechanism on qemu and bochs.

My question is in regard to GRUB. Does BIOS find GRUB in the same way that it finds the boot sector I wrote? I did a hexdump on the binary GRUB file and was unable to find the magic number 0x55aa at the end of a 512 byte sector

Another way to ask the question, which really highlights my lack of understanding, would be as follows:

What is the purpose of the magic number 0x55aa in relation to BIOS and the booting process? What is the purpose of the magic number 0x1BADB002 in relation to GRUB and the booting process? Additionally:

• Does BIOS locate boot loaders via the magic number 0x55aa? If not, what does it locate with that magic number? My understanding was that the boot sector is the sector that contains the boot loader code, and that sector need have the magic number 0x55aa.

I really felt like I was understanding everything writing my own boot sector in 16-bit real mode, entering 32 bit protected mode, and bootstrapping to C. Then when I learned about GRUB I felt like I don't understand anything anymore. i tried to read and google, please help

Much love!

The boot sector is meant to be the first sector of an hard-disk. It just happens that, with QEMU, you can specify any file type to be the hard-disk. This is a really great functionality because it allows to create a raw virtual hard-disk with dd.