Master boot record
lastmod 2020-07-04created 2020-06-287 edits
A master boot record (MBR), or partition sector, is the 512-byte boot sector that is the first sector (sector 0) of a partitioned storage device (such as a hard disk). (The boot sector of a non-partitioned device is a volume boot record.)
Uses
The MBR is used for one or more of the following:
- Holding the disk's primary partition table.
- Bootstrapping an operating system (after the computer's BIOS passes execution to machine code instructions contained within the MBR)
- Identifying individual disk media with a 32-bit disk signature
Because of the popularity of IBM PC compatible computers, this type of MBR is widely used, to the extent of being supported by and integrated into other computers.
Data structure
| Address | Description | Size | ||
| Hex | Dec | |||
| | 0 | Code area | 440 | |
| | 440 | Disk signature | 4 | |
| | 444 | Usually null; 0x0000 | 2 | |
| | 446 | Primary partition table | 64 | |
| | 510 | 55h | MBR signature; | 2 |
| | 511 | AAh | ||
| MBR, total size: 446 + 64 + 2 = | 512 | |||
MBR and the disk partitioning process
| Offset | Description |
| 0x00 | (1 byte) Partition status (0x80 = bootable, 0x00 = non-bootable, other = invalid) |
| 0x01 | (3 bytes) Cylinder-head-sector address of the first sector of the partition |
| 0x04 | (1 byte) Partition type |
| 0x05 | (3 bytes) Cylinder-head-sector address of the last sector of the partition |
| 0x08 | (4 bytes) Logical block addressing (LBA) of the first sector of the partition |
| 0x0C | (4 bytes) Size of the partition (in sectors) |
A storage device partitioned according to the MBR partition table scheme (= the IBM PC partitioning scheme convention) has primary partition entries in the MBR's partition table.
By convention the MBR partition scheme should have only 4 primary partition entries, but some DOS operating systems extended this to 5 entries (PTS-DOS) or 8 entries (AST and NEC DOS).
A storage device partitioned with the GUID partition table scheme also has a partition table in the MBR. Its only purpose is to indicate that a GUID partition exists, so that programs that only understand the MBR partition table scheme do not treat the (GUID-partitioned) storage device as empty and create partitions on it.
MBR and bootstrapping
On IA-32 IBM PC compatibles using the MBR partition table scheme, the ROM BIOS (bootstrapping) firmware reads and executes the MBR. Because i386-family processors start in real mode, the MBR code must be real-mode code. Typically the MBR code passes boot control to the volume boot record of the boot partition by chain loading, but some boot managers use their own methods instead of this typical one.
The MBR code finds the one partition in the partition table (according to the MBR partition table scheme) that has the active flag, then reads and executes that partition's volume boot record. (This is why the master boot record, like other boot sectors, is a target of boot sector viruses.)
Partition table entries
An artifact of hard disk technology from the era of the PC XT, the partition table subdivides a storage medium using units of cylinders, heads, and sectors (CHS addressing). These values no longer correspond to their namesakes in modern disk drives, as well as being irrelevant in other devices such as solid-state drives, which do not physically have cylinders or heads.
Track partition alignment
Track partition alignment, partitions starting on track boundaries on hard disk drives.