Linux – the role of Magic Number in boot loading in Linux?

linux

I was going through the details of the linux boot process. It was understood that the primary boot loader resides in 512 byte image (program code + partition table). The 510 bytes comprise of executable code, error messages and partition table information. And the last 2 bytes contain a magic number 0xAA55. It was mentioned that "The magic number serves as a validation check of the MBR". Now what is the validation check? My guess is that it is some sort of check like CRC to make sure that MBR is not corrupt.

I searched on the net and there is no explanation for magic numbers and its working. But interesting thing is even Microsoft OS' also have magic numbers in their boot loaders. Can somebody enlighten us in this regard??????????????

Best Solution

Hi I hope this will help you:

http://en.wikibooks.org/wiki/X86_Assembly/Bootloaders

http://en.wikipedia.org/wiki/Extended_boot_record

"The 0xAA55 signature is the last two bytes of the first sector of your bootdisk (bootsector/Master Boot Record/MBR). If it is 0xAA55, then the BIOS will try booting the system. If it's not found (it garbled or 0x0000), you'll get an error message from your BIOS that it didn't find a bootable disk (or the system tries booting the next disk). This signature is represented (in binary) as 0b1010101001010101. The alternating bit pattern was thought to be a protection against certain failures (drive or controller).

Of course, this is an i386ism (also present on amd64 I believe). Lots of other architectures may take different approaches."

http://www.mail-archive.com/misc@openbsd.org/msg18029.html