mbr

Master Boot Record maximum drive size


I am reading up a bit on Master Boot Record layout and I was particularly interested in how the partition layout causes a size limitation on the size of the storage that can be used on a device with MBR.

Each partition within an MBR is defined using a 16 byte entry. The usage of those 16 bytes is as follows:

Suppose we have only 1 partition in MBR and I make that the active partition. The zeroth sector is occupied by the MBR itself while the first partition starts from sector 1. Then the total number of sectors in this partition are:

2^10 = 1024 (number of tracks)
2^6 = 64 (number of sectors)
2^8 = 256 (number of heads)

1024 * 64 * 256 = 16,777,216 sectors

With every sector containing 512 bytes we get a maximum partition size of 8,589,934,592 (8.5 GB). If this is correct (which I doubt), shouldn't the maximum size of a disk addressable by MBR be 8.5 GB? I see everywhere they talk of 2.1 TBs and I am unable to understand how.


Solution

  • CHS addressing is long since obsolete. Recent MBR systems store partition information as LBA ("logical block address") and the drive internally maps it to cylinders/heads/sectors (after performing any necessary remapping for bad/spare sectors).

    According to Wikipedia, LBA offset and size are stored as 32-bit little-endian values at offsets 0x08 and 0x0c (respectively) of a MBR partition table entry. This corresponds to your bytes 9-16.

    32-bit addresses mean that limitation is in fact 2^32 * 512 = 2TB. This limitation is one of the main reasons why modern systems use GPT partitioning. Many drives also use 4096-byte sectors instead of 512.