The master boot record (MBR) is a small program that is executed when a computer is booting (i.e., starting up) in order to find the operating system and load it into memory.
During the first stage of the boot process, the BIOS (basic input output system) searches for the MBR and then loads it into memory, after which the MBR takes over. The BIOS is a small program that usually resides in a flash memory chip. Flash memory is a type of memory that retains its contents even in the absence of a power supply.
The BIOS will search for an MBR in any of several devices or media, such as the hard disk drive (HDD), floppy disk, CDROM and USB (universal serial bus) key drive, with the search sequence depending on how the BIOS has been configured. The BIOS loads the first MBR that it locates, which is usually the one on the HDD. The BIOS looks for the MBR on the HDD in a standard location, which is the first sector and the first head in the first cylinder (designated as cylinder 0, head 0, sector 1). This is commonly referred to as the boot sector.
A sector is a segment of a track on a magnetic disk (i.e., a floppy disk or a platter in a HDD). It generally contains 512 bytes and is the smallest unit of data that can be accessed by a disk drive. A platter is a thin, high-precision aluminum or glass disk that is coated on both sides with a high-sensitivity magnetic material and which is used by a HDD to store data. Modern HDDs contain multiple platters, all of which are mounted on a single shaft, in order to maximize the data storage surface in a given volume of space.
The magnetic coating on each side of each platter is divided into a series of tracks. A track is any of the concentric circles over which one head passes while it is stationary but the platter is rotating at high speed. A head is a small, high-sensitivity electromagnet that is used for reading and writing data on the magnetic material. A cylinder is any set of all of the tracks of equal diameter in a HDD; it can be visualized as a single, imaginary, circle that cuts through all of the platters in the drive. The first cylinder is the outermost one.
When booting from the HDD, the BIOS loads the contents of the MBR to a fixed address in the memory and allows it to take control. This code then loads the operating system from a bootable partition or it loads a complex boot loader, such as LILO (Linux loader) or GRUB (grand unified boot loader), which then loads the operating system. A partition is a logically independent section of a HDD.
64 bytes of the boot sector is consumed by the partition table, which is a data structure that provides basic information for a computer’s operating system about the division of the HDD into primary partitions. A data structure is an efficient way of organizing data. Primary partitions are the first four partitions on a HDD. The final two bytes of this sector are a signature to indicate the end of the boot sector.
This leaves only 446 bytes for the code used by the MBR to perform its tasks of locating the partition that is marked active (which is referred to as the active partition), loading the first sector from that partition into the appropriate memory address, and then transferring execution to that code.
An active partition is a partition that contains the operating system that a computer attempts to load into memory by default when it is started or restarted. There can be only one active partition on a HDD. A boot loader such as LILO or GRUB makes it possible for a computer to boot into partitions other than the active partition, including logical partitions. A logical partition is a partition that has been created inside of a primary partition.