Master boot record
Encyclopedia : M : MA : MAS : Master boot record
| Address | Description |
|---|---|
| 0x0000 | Code Area |
| 0x018A | Four 9 byte primary partition table entries (IBM extensions to the MBR Partition Table scheme) |
| 0x01B8 | 4 byte disk signature |
| 0x01BE | Four 16 byte primary partition table entries (MBR Partition Table scheme only) |
| 0x01FE | 2 byte MBR signature (0xAA55) |
MBRs and disc partitioning
| Offset | Description |
|---|---|
| 0x00 | 2) |
| 0x01 | Cylinder-head-sector address of the first sector in the partition |
| 0x04 | Partition type |
| 0x05 | |
| 0x08 | Logical block address of the first sector in the partition |
| 0x0C | Length of the partition, in sectors |
| Offset | Description |
|---|---|
| 0x00 | |
| 0x01 | Space-padded partition name |
By convention, there are exactly four primary partition table entries in the MBR Partition Table scheme, although some (rare) systems have been known to extend this to five, or to eight, entries.
Where a data storage device has been partitioned with the GUID Partition Table, the Master Boot Record does not contain the partition table (although it contains dummy data structures, a "protective MBR", to prevent utility programs that only understand the MBR Partition Table scheme from creating partitions on the disc) and is wholly unused as far as disc partitioning is concerned.
MBRs and system bootstrapping
On IA-32 IBM PC compatible machines using the MBR Partition Table scheme, the bootstrapping firmware contained within the ROM BIOS loads and executes the master boot record. Because the i386 family of processors boot up in real mode, the code in the MBR comprises real mode machine language instructions. This code in its turn normally comprises code for chain loading the Volume Boot Record of the active (primary) partition, although some boot managers replace that conventional code with their own.The conventional MBR code expects the MBR Partition Table scheme to have been used, and scans the list of (primary) partition entries in its embedded partition table to find one that is marked with the active flag. It then loads and runs the Volume Boot Record for that partition. Thus the BIOS boots an operating system without being aware of the actual disc partition that contains that operating system, or of being aware of disc partitioning at all. (And thus the Master Boot Record, like other boot sectors, is a target for boot-sector infecting computer viruses. See boot sector.)
The MBR replacement code in some boot managers can perform a variety of tasks, and what those tasks are varies from boot manager to boot manager. In some, for example, it loads the remainder of the boot manager code from the first track of the disc, which it assumes to be "free" space that is not allocated to any disc partition, and executes it. In others, it uses a table of embedded disc locations to locate the remainder of the boot manager code to load and to execute. (Both approaches have problems. The first relies on behaviour that is not universal across all disc partitioning utilities. The second requires that the embedded list of disc locations be updated when changes that would relocate the remainder of the code are made.)
On machines that do not use IA-32 processors, or on machines that use the GUID Partition Table scheme, this design is unsuitable, and the MBR is not used as part of the system bootstrap. Instead the firmware is capable of directly understanding the GPT partitioning scheme and the FAT filesystem format, and loads and runs programs held as files in the EFI System Partition. The MBR is not involved in system bootstrapping (except indirectly, insofar as it might contain the partition table if the MBR Partition Table scheme has been used) at all.
MBRs and disc identity
In addition to bootstrap code and partition tables, a third thing that may be contained in a Master Boot Record is a Windows NT disk signature. This is a 32-bit value that is intended to uniquely identify the disc medium (as opposed to the disc unit — the two not necessarily being the same for removable hard discs).The disc signature was introduced by Windows NT version 3.5, but is now used by several operating systems, including version 2.6 and later of the Linux kernel. Windows NT uses the disc signature as an index into its registry, where it stores the persistent mappings between disc partitions and drive letters. It also uses it in the boot.ini file to describe the location of bootable Windows NT partitions. Linux uses the disc signature at boot time to determine the location of the boot volume.
Footnotes
- Note 1: The status fields in the unextended partition table records are used by the embedded bootstrap code within the MBR itself to determine which partitions are bootable. (In IBM nomenclature, such partitions are described as startable. In other nomenclature they are described as active.) The status fields in the extended partition table records are used by boot manager programs to determine which partitions are bootable. (In IBM nomenclature, such partitions are described as bootable.) In the conventional case, the "startable" partition contains a boot manager, which displays a list of the "bootable" partitions when it is itself bootstrapped.
- Note 2: In theory, values other than 0x00 and 0x80 in this field have undefined meanings. In practice, their meaning depends from what the bootstrap code within the MBR itself has been written to accept. Some MBR bootstrap programs specifically look for the value 0x80 to indicate a bootable ("startable") partition. Others simply look for a non-zero value.
- Note 3: These fields have a limit of 1024 cylinders, 256 heads, and 64 sectors. If a CHS address is too large to fit into these fields, the tuple (1023,255,63) is used.
backing up the BIOS
in UNIX/Linux dd can be used to backup and restore the MBR to backupdd if=/dev/xxx of=mbr.backup bs=512 count=1to restore
dd if=mbr.backup of=/dev/xxx bs=1where xxx is the device. can be hda,sda, or anyother.
References
Further reading
See also
- Boot loader
- BIOS interrupt call
From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.
