Writing an OS Kernel from Scratch | GPT Partition: How to Break MBR’s 2TB Limit and Manage 128 Partitions
In the previous article we covered MBR — the 512-byte first sector, 446 bytes of bootloader plus 64 bytes of partition table. MBR dominated PC partitioning standards for 30 years, but it has two unavoidable hard limitations: a maximum of 4 partitions and a maximum disk capacity of 2TB.
Entering the 2000s, large-capacity hard drives became popular, and MBR began to be a bottleneck. Intel led the design of a new generation partitioning standard — GPT (GUID Partition Table). It’s not an upgrade of MBR, but a complete rewrite: the number of partitions expanded from 4 to 128, the capacity limit jumped from 2TB to 8ZB (ZettaByte), and the boot method changed from “the first sector of the disk” to a “dedicated EFI partition.”
Today, we’ll break down the complete structure of GPT — how it’s organized, where the functions MBR used to handle went, and what new capabilities GPT brings that MBR never had.
MBR’s Three Responsibilities, All Redone by GPT
MBR took on three completely different tasks on the disk:
| MBR Function | Specific Content | GPT’s Corresponding Solution |
|---|---|---|
| Boot Code | BOOTMGR / GRUB Stage 1, 446 bytes | Moved to ESP (EFI System Partition), no longer in MBR |
| Partition Table | 4 entries × 16 bytes = 64 bytes, max 4 primary partitions | Independent partition table area (128 entries × 128 bytes = 16KB) at LBA 2-33 |
| Boot Signature | 0x55AA, determines if disk is bootable | Not needed, replaced by CRC32 checksum in GPT Header |
MBR mixed three completely different things together — code + data + metadata. GPT’s approach is: Boot matters belong to boot, partition matters belong to partitions — each does its own job without interfering with the others.
GPT Physical Layout: How the Disk Is Arranged
GPT divides the disk from start to end into several regions, each with clear responsibilities:
Complete GPT Disk Layout (using a 1TB disk as example):
┌─────────────────────────────────────────────────────────────────┐
│ LBA 0 (512 bytes): Protective MBR │
│ • Prevents old systems from misidentifying a GPT disk as │
│ "unpartitioned" │
│ • First partition entry: type=0xEE, start=1, size=entire disk │
│ • Last two bytes: 0x55AA (lets BIOS think this is a │
│ "bootable" MBR disk) │
├─────────────────────────────────────────────────────────────────┤
│ LBA 1 (512 bytes): GPT Header │
│ • Signature "EFI PART" (46 49 52 50 41 52 54) │
│ • Partition table location (at LBA 2) │
│ • Partition table size (128 entries × 128 bytes = 16KB) │
│ • Number of partition entries (128) │
│ • Current disk GUID (unique identifier) │
│ • Backup GPT Header location (LBA -1, i.e., second-to-last │
│ sector) │
├─────────────────────────────────────────────────────────────────┤
│ LBA 2 - LBA 33 (32 sectors = 16KB): Primary Partition Table │
│ • 128 partition entries, each 128 bytes │
│ • ... [truncated]
Comments