Linux Tutorial

Linux File/Directory Management

Linux Packaging And Compression

Vim Text Editor

Linux Text Processing

Linux Software Installation

Linux User/User Group Management

Linux Permission Management

Linux Filesystem Management

Linux Advanced Filesystem Management

Linux System Management

Linux Backup and Recovery

Linux System Service Management

Linux System Log Management

Linux Boot Management

LAMP/LNMP Environment

SELinux Management

The Structure And Function Of The Master Boot Directory (MBR)

The Master Boot Record (MBR) is an essential component in the boot process of a computer system, particularly in the context of BIOS-based systems. It is a data structure located in the first sector (sector 0) of a storage device, such as a hard disk or USB drive, and contains critical information for the operating system (OS) to locate and load partitions, as well as a bootloader program to start the OS.

Structure of MBR

The MBR is 512 bytes in size and has the following structure:

  1. Bootstrap code (446 bytes): The first 446 bytes of the MBR contain the bootstrap code (or bootloader), a small program that runs when the computer starts. This code locates the active partition and executes the next stage bootloader or the operating system itself, depending on the system's configuration.

  2. Partition table (64 bytes): The partition table is a data structure containing four 16-byte entries, each of which describes a partition on the storage device. Each entry contains information such as the partition's starting and ending sector, partition size, file system type, and status (e.g., active or bootable).

  3. Signature (2 bytes): The last two bytes of the MBR are the signature bytes (0x55 and 0xAA), which signify a valid MBR. The BIOS checks for this signature during the boot process to verify that the MBR is present and valid.

Function of MBR

The primary function of the MBR is to facilitate the boot process. When the computer starts up, the BIOS performs a Power-On Self Test (POST) to check hardware components. After the POST, the BIOS searches for a bootable device (e.g., a hard drive or USB drive) with a valid MBR. Once it locates the MBR, it reads and executes the bootstrap code.

The bootstrap code searches the partition table to find the active partition. Once it identifies the active partition, it reads and executes the next stage bootloader (or the operating system, if the MBR directly loads it). This process continues until the operating system is loaded into memory and starts running.

It is important to note that the MBR is specific to BIOS-based systems. Newer systems with Unified Extensible Firmware Interface (UEFI) use the GUID Partition Table (GPT) instead of the MBR. However, MBR remains widely used, and many systems provide backward compatibility to support both MBR and GPT.

In conclusion, the Master Boot Record (MBR) plays a crucial role in the boot process for BIOS-based computer systems. Its structure consists of bootstrap code, a partition table, and a signature, all of which contribute to locating and loading the operating system during startup.