MBR组织

MBR organization

MBR 分区table 中偏移8 字节的字段用于存储分区开头的LBA 地址。当没有足够的 CHS 坐标时,引入 LBA 寻址来寻址更大的磁盘。但是在引入 MBR 支持时,这样的磁盘还不存在。因此问题来了:偏移量为 8 字节和 12 字节的字段最初包含什么?它们是为进一步的结构开发保留的还是有其他目的?

我也对 LBA-48 的实现感兴趣。 MBR中分配了32位用于存储LBA地址,那么48位地址如何存储在32位中?

两篇维基百科文章提供了有用的详细信息: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"

在 MBR 中有 "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扇区大小过去被认为固定为 512 (29) 字节”。

使用 4 个字节,我们可以将最大 2 TB 的磁盘大小编码为 4294967295(2 到 32 的幂减 1)乘以每个扇区 512 字节(2147483647.5 千字节)。

LBA-48 不能存储在官方支持的 MBR 分区条目中,因为 48 位是 6 个字节和 MBR(和 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.

(在一些类似 wiki 的随机站点中有 proposed incompatible MBR format for LBA48,但它不适用于大多数 OS 期望正确的经典 MBR。)

LBA 于 1996 年引入,“在 Windows 95B 和 DOS 7.10 中以支持大于 8 GB 的磁盘”,如 the Wikipedia. There is related IBM patent granted in 1999 (expired probably in October 2019): Address offset feature for a hard disk drive, US6415383

关于 MBR 的前 LBA 时代知之甚少,但在 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)

即使是 Starman 的 MBR 资源也没有关于原因的信息 为什么 为每个分区 table 条目分配 16 个字节。

我发现了 AST Research(现已转让给三星)1990-1992 年早些时候的专利,System for multiple access hard disk partitioning, US5136711A 它给出了图 2(图 3)中的分区 table 布局,听起来非常像 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.

分区 table 140 在图像中定义为:

  • 141开机指示灯,
  • 142头号,
  • 144扇区号,
  • 气缸数,
  • 148个系统指标,
  • 150头号,
  • 152扇区号,
  • 气缸数,
  • 154引导扇区地址,
  • 156扇区号

并且在 AST 1992 专利分区的文本中 table 描述为:

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.

所以,在我的假设中,+8 字段可能用于指向分区的引导扇区(它可能不在第一个扇区?),+12 可能用于检查分区大小计算。但是在 DOS2 code 中没有实际读取 +8 和 +12 字段。它们可能只是保留在 IBM MBR 中,并在 AST 专利中重复使用,用于一些类似 LBA 的用法。

1991 年的 PCMag (PC Mag 10 Sep 1991, page 410) 还说 4 字节字段已经用于类似 LBA 的扇区地址:

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.

与 1992 年 Mark Minasi 的书 "The Hard Disk Survival Guide" 相同,至少最后一个 +12 字段(分区大小),第 279 页(google 书中有一些片段):

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.