Reading another question on here it made me curious if it's possible to actually read the contents of the mbr. As I understand it, there's a certain area at the very front of the partition that lists this information. I'm curious if it's sort of like an ini file or some sort of script that runs and tells the computer what it needs to know about where to boot from and other information like sectors, heads, cylinders that's important. I don't know much about what would be in it, but I thought it'd be interesting to learn more about the specifics.
33 Answers
On a Unix-type system (Linux, MacOS, etc), you simply read from the hard drive's character device (/dev/sda perhaps), and access the MBR that way. On Windows you could get a windows version of the dd program and use that to look at the bytes you are interested in.
Now, as to what's in the MBR, you might want to look at the Wikipedia page for a beginning. Hint: No, it's not a script.
3For MBR disk
dd if=/dev/sda bs=512 count=1 | hexdump -C For GPT disk
A=(128*B)+1024 B=parted -ms /dev/sda print |tail -1|cut -b1 dd if=/dev/sda of=GPT_TABLE bs=1 count=A | hexdump -C More info at Here
The MBR is just the 1st 512-byte sector of a disk (if it has one). I can open any disk in read-only mode using the hex editor HxD, and read any sector. The MBR contains a few short error messages in text, but the rest is machine code and formatted partition table entries. There's lots of interesting info about Windows MBR code at