Master Boot Record (MBR) and GPT (GUID Partition Table)
The MBR Partitioning Scheme
The MBR is a small program which runs whenever a computer boots up. The MBR is stored in the first sector of the boot disk. The boot disk may be a hard drive, a floppy drive, or even a CD or DVD drive.
The normal job of the MBR program is to search the partition table for the active partition, copy the boot sector from the active partition into memory, and transfer control over to that program.
If the MBR cannot accomplish this task successfully, it will print one of these error messages:
- Invalid partition table
- Error loading operating system
- Missing operating system
If a mass storage device is connected to a Linux computer, the Linux kernel tries to locate any partitions. So to use a hard drive we need to partition it. Commonly, two different partitioning schemes are available: the Master Boot Record and GUID Partition Table. Linux typically has multiple partitions on one hard disk, this makes sense for different reasons:
- Distinguish different types of data.
- Mount options to enhance security or performance.
- Create backup strategies where only relevant portions of the OS are backed up.
- If one partition accidentally fills up completely other partitions are still usable and your system might not crash immediately.
In the early 1980s the Master Boot Record partitioning scheme was invented to define hard disk layout. On BIOS-based systems the BIOS searches for an operating system on the bootable disk device where the first 512 bytes [000-1FF] of the boot medium is read.
The MBR is defined as these first 512 bytes which contains an operating system boot loader (446 bytes [000-1BD]) and a partition table (64 bytes [1BE-1FD]). The size used for the partition table, means no more than 4 partions can be created with a maximum size of 2 TB per partition. The last 2 bytes [1FE, 1FF] (0x55, 0xaa) of the first 512 byte sector signifies the device is bootable. These two bytes are also call the “magic number”.
To go beyond the limit of 4 partitions, one partition could be created as an extended partition (as opposed to a primary partition) where multiple logical partitions can be created within to reach a total of 15 partitions addressable by the Linux kernel.
The GPT Partitioning Scheme
Current hard drives have become too big to be addressed by MBR partitions, the GUID Partition Table counters this. On computers that use the new Unified Extensible Firware Interface (UEFI) instead of BIOS, GPT partitions are the only way to address disks.
Systems using BIOS can use GUID partitions and must do so if a disk bigger than 2 TB needs to be addressed. Although not being used by UEFI devices, the MBR is present at the beginning of the disk, in block LBA0, for protective and compatibility purposes. Strictly speaking, the GPT starts up from the Partition Table Header.
The benefits of using GUID:
- a 8 ZB partition size (1024^4).
- Maximum 128 partitions.
- No distinguishment between primary, extended and logical partitions.
- Uses 128-bit global unique identifier (GUID) to identify partitions.
- A backup of the GUID partition table is created at the end of the disk (Secondary GPT Header), eliminating the single point of failure of MBR partition tables.