filesystemsdiskmbr

MBR organization


The field in the MBR partition table with 8 bytes offset is intended to store the LBA-address of the partition beginning. LBA addressing was introduced to address larger disks when there were not already enough CHS-coordinates. But at the time of the introduction of MBR support, such disks did not exist yet. Hence the question: what did the fields with offsets of 8 and 12 bytes initially contain? Were they reserved for the further structure development or had some other purpose?

Also I an interested in the implementation of LBA-48. 32 bits are allocated for storing an LBA address in the MBR, so how can a 48-bit address be stored in 32 bits?


Solution

  • Two wikipedia articles gives useful details: https://en.wikipedia.org/wiki/Master_boot_record and https://en.wikipedia.org/wiki/Logical_block_addressing. Other useful source is The Starman's "All the Details of many versions of both MBR".

    In MBR there are "Partition table entries"; and for LBA-compatible entries thay have both CHS (3 byte) and LBA (4 byte) addresses. CHS gives two addresses, one for first sector of the partition and other for last sector of the partition. And LBA addresses are LBA address of first sector and total number of sectors in this partition. So both types of addresses are not for bytes but for sectors, and Wikipedia says "The sector size used to be considered fixed at 512 (29) bytes".

    With 4 bytes we can encode maximum sizes of the disk up to 2 TB as 4294967295 (2 to 32 power minus 1) multiplied by 512 bytes per sector (2147483647.5 kilobytes).

    LBA-48 can't be stored in the officially supported MBR partition entry, as 48 bits is 6 bytes and MBR (and EBR for 5th logical partition) have only 4 bytes to store LBA start and end sector addresses. LBA-48 is used with GUID GPT - https://en.wikipedia.org/wiki/Logical_block_addressing#LBA48

    The current 48-bit LBA scheme was introduced in 2003 with the ATA-6 standard,[4] raising the addressing limit to 2^48 × 512 bytes, which is exactly 128 PiB or approximately 144.1PB. ... However, the common DOS style Master Boot Record (MBR) partition table only supports disk partitions up to 2 TiB in size. For larger partitions this needs to be replaced by another scheme, for instance the GUID Partition Table (GPT) which has the same 64-bit limit as the current INT 13h Extensions.

    (There is proposed incompatible MBR format for LBA48 in some random wiki-like site, but it will not work with most OS which are expecting correct classic MBR.)

    LBA was introduced in 1996 "in Windows 95B and DOS 7.10 in order to support disks larger than 8 GB" as says the Wikipedia. There is related IBM patent granted in 1999 (expired probably in October 2019): Address offset feature for a hard disk drive, US6415383

    Little is known about pre-LBA epoch of MBR, but in DOS 2.0 partition table had 64 bytes total size with 4 partitions and 16 bytes per partition. It was the size encoded in MBR parsing code in DOS2:

    An Examination of the Assembly Code

    062C 83C610       ADD  SI,+10            ; Checking the next entry...
                                             ; (10h = 16 bytes per entry)
    

    Even The Starman's MBR resource have no information on reasons why 16 bytes were allocated for every partition table entry.

    I found earlier 1990-1992 patent of AST Research (now assigned to Samsung), System for multiple access hard disk partitioning, US5136711A which gives partition table layout in Image 2 (Figure 3) with something which sounds very like LBA:

    Each of the partition identifier segments 133, 134, 135, and 136 comprises 16 bytes of disk space making up a partition table 140 (FIG. 3) containing identification information for the corresponding disk partition.

    Partition table 140 was defined in image as:

    And in text of AST 1992 patent partition table described as:

    The partition table 140 comprises a boot indicator byte 141 to identify whether the corresponding partition segment P4 is a bootable partition or a non-bootable partition. Only one partition of P4, P3, P2, and P1 may be bootable at a given time. The partition table further comprises a physical starting head number byte 142, a physical starting cylinder and physical starting sector segment 144, a system indicator byte 148 which identifies the type of operating system, a physical ending head number byte 150, a physical ending cylinder and physical ending sector segment 152, a boot sector address segment 154, and a sector number segment 156 which indicates the number of sectors in the partition P4 as is well understood in the art.

    So, in my hypothesis probably field +8 may be used to point to boot sector of the partition (it may be placed not in the first sector?) and +12 may be used to check partition size calculations. But in DOS2 code there was no actual reading of +8 and +12 fields. They may be just reserved in IBM MBR and reused in AST patent for some LBA-like usage.

    PCMag from 1991 (PC Mag 10 Sep 1991, page 410) also says that 4-byte fields were already used for LBA-like sector addresses:

    Each record in the partition table is 16 bytes, including 4 each for the starting sector and the number of sectors. In addition, one byte is reserved for the partition byte.

    Same for 1992 Mark Minasi book "The Hard Disk Survival Guide" at least for last +12 field (partition size), page 279 (there are some snippets in google books):

    Getting this number to fix a boot record is simple: It is in the MBR. The last four bytes of each partition table entry is the partition length in secotrs.