Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the role of Magic Number in boot loading in Linux? [closed]

Tags:

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??????????????

like image 789
rocknroll Avatar asked Jul 14 '09 12:07

rocknroll


2 Answers

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/[email protected]/msg18029.html

like image 117
expEng Avatar answered Oct 16 '22 03:10

expEng


Not a checksum, but more of a signature. It does provide some simple evidence that some MBR is present.

0xAA55 is also an alternating bit pattern: 1010101001010101

It's often used to help determine if you are on a little-endian or big-endian system, because it will read as either AA55 or 55AA. I suspect that is part of why it is put on the end of the MBR.

See also this Wikipedia article

like image 21
Chris Arguin Avatar answered Oct 16 '22 04:10

Chris Arguin