Master boot record
A master boot record (MBR) is a special type of
The MBR holds the information on how the disc's sectors (aka "blocks") are divided into partitions, each partition notionally containing a file system. The MBR also contains executable code to function as a loader for the installed operating system—usually by passing control over to the loader's second stage, or in conjunction with each partition's volume boot record (VBR). This MBR code is usually referred to as a boot loader.
The organization of the partition table in the MBR limits the maximum addressable storage space of a partitioned disk to 2
MBRs are not present on non-partitioned media such as
Overview
Support for partitioned media, and thereby the master boot record (MBR), was introduced with IBM
In 1996, support for
.Despite sometimes poor documentation of certain intrinsic details of the MBR format (which occasionally caused compatibility problems), it has been widely adopted as a de facto industry standard, due to the broad popularity of PC-compatible computers and its semi-static nature over decades. This was even to the extent of being supported by computer operating systems for other platforms. Sometimes this was in addition to other pre-existing or
MBR partition entries and the MBR boot code used in commercial operating systems, however, are limited to 32 bits.[1] Therefore, the maximum disk size supported on disks using 512-byte sectors (whether real or emulated) by the MBR partitioning scheme (without 32-bit arithmetic) is limited to 2 TiB.[1] Consequently, a different partitioning scheme must be used for larger disks, as they have become widely available since 2010. The MBR partitioning scheme is therefore in the process of being superseded by the GUID Partition Table (GPT). The official approach does little more than ensuring data integrity by employing a protective MBR. Specifically, it does not provide backward compatibility with operating systems that do not support the GPT scheme as well. Meanwhile, multiple forms of hybrid MBRs have been designed and implemented by third parties in order to maintain partitions located in the first physical 2 TiB of a disk in both partitioning schemes "in parallel" and/or to allow older operating systems to boot off GPT partitions as well. The present non-standard nature of these solutions causes various compatibility problems in certain scenarios.
The MBR consists of 512 or more bytes located in the first sector of the drive.
It may contain one or more of:
- A partition tabledescribing the partitions of a storage device. In this context the boot sector may also be called a partition sector.
- chain loader.
- Optional 32-bit disk timestamp.[2]
- Optional 32-bit disk signature.[4][5][6][7]
Disk partitioning
The partitions themselves may also contain data to describe more complex partitioning schemes, such as extended boot records (EBRs), BSD disklabels, or Logical Disk Manager metadata partitions.[8]
The MBR is not located in a partition; it is located at a first sector of the device (physical offset 0), preceding the first partition. (The boot sector present on a non-partitioned device or within an individual partition is called a
Sector layout
By convention, there are exactly four primary partition table entries in the MBR partition table scheme, although some operating systems and system tools extended this to five (Advanced Active Partitions (AAP) with
Address | Description | Size (bytes) | |
---|---|---|---|
0x0000 (0)
|
Bootstrap code area | 446 | |
0x01BE (446)
|
Partition entry №1 | Partition table (for primary partitions) |
16 |
0x01CE (462)
|
Partition entry №2 | 16 | |
0x01DE (478)
|
Partition entry №3 | 16 | |
0x01EE (494)
|
Partition entry №4 | 16 | |
0x01FE (510)
|
0x55
|
Boot signature[a] | 2 |
0x01FF (511)
|
0xAA
| ||
Total size: 446 + 4×16 + 2 | 512 |
Address | Description | Size (bytes) | |
---|---|---|---|
0x0000 (0) |
Bootstrap code area (part 1) | 218 | |
0x00DA (218)
|
0x0000
|
Disk timestamp[2][b] (optional; Windows 95B/98/98SE/ME (MS-DOS 7.1–8.0). Alternatively, can serve as OEM loader signature with NEWLDR) | 2 |
0x00DC (220)
|
Original physical drive (0x80 –0xFF )
|
1 | |
0x00DD (221)
|
Seconds (0–59) | 1 | |
0x00DE (222)
|
Minutes (0–59) | 1 | |
0x00DF (223)
|
Hours (0–23) | 1 | |
0x00E0 (224) |
Bootstrap code area (part 2, code entry at 0x0000 )
|
216 (or 222) | |
0x01B8 (440)
|
32-bit disk signature | Disk signature (optional; UEFI, Linux, Windows NT family and other OSes)
|
4 |
0x01BC (444)
|
0x0000 (0x5A5A if copy-protected)
|
2 | |
0x01BE (446)
|
Partition entry №1 | Partition table (for primary partitions) |
16 |
0x01CE (462)
|
Partition entry №2 | 16 | |
0x01DE (478)
|
Partition entry №3 | 16 | |
0x01EE (494)
|
Partition entry №4 | 16 | |
0x01FE (510)
|
0x55
|
Boot signature[a] | 2 |
0x01FF (511)
|
0xAA
| ||
Total size: 218 + 6 + 216 + 6 + 4×16 + 2 | 512 |
Address | Description | Size (bytes) | |
---|---|---|---|
0x0000 (0) |
Bootstrap code area | 428 | |
0x01AC (428)
|
0x78
|
AAP signature (optional) | 2 |
0x01AD (429)
|
0x56
| ||
0x01AE (430)
|
AAP physical drive (0x80 –0xFE ; 0x00 : not used; 0x01 –0x7F , 0xFF : reserved)
|
AAP record (optional) (AAP partition entry #0 with special semantics) | 1 |
0x01AF (431)
|
CHS (start) address of AAP partition/image file or VBR/EBR | 3 | |
0x01B2 (434)
|
Reserved for AAP partition type (0x00 if not used) (optional)
|
1 | |
0x01B3 (435)
|
Reserved for CHS end address in AAP (optional; byte at offset 0x01B5 is also used for MBR checksum (PTS DE, BootWizard); 0x000000 if not used)
|
3 | |
0x01B6 (438)
|
Start LBA of AAP image file or VBR/EBR or relative sectors of AAP partition (copied to offset +01Chex in the loaded sector over the "hidden sectors" entry of a DOS 3.31 BPB (or emulation thereof) to also support EBR booting)
|
4 | |
0x01BA (442)
|
Reserved for sectors in AAP (optional; 0x00000000 if not used)
|
4 | |
0x01BE (446)
|
Partition entry №1 | Partition table (for primary partitions) |
16 |
0x01CE (462)
|
Partition entry №2 | 16 | |
0x01DE (478)
|
Partition entry №3 | 16 | |
0x01EE (494)
|
Partition entry №4 | 16 | |
0x01FE (510)
|
0x55
|
Boot signature[a] | 2 |
0x01FF (511)
|
0xAA
| ||
Total size: 428 + 2 + 16 + 4×16 + 2 | 512 |
Address | Description | Size (bytes) | |
---|---|---|---|
0x0000 (0)
|
JMPS (EBhex ) / NEWLDR record size (often 0x0A /0x16 /0x1C for code start at 0x000C /0x0018 /0x001E )
|
NEWLDR record (optional) | 2 |
0x0002 (2)
|
"NEWLDR " signature
|
6 | |
0x0008 (8)
|
LOADER physical drive and boot flag (0x80 –0xFE , 0x00 –0x7E , 0xFF , 0x7F ) (if not used, this and following 3 bytes must be all 0)
|
1 | |
0x0009 (9)
|
IBMBIO.LDR ) (0x000000 if not used)
|
3 | |
0x000C (12)
|
Allowed DL minimum, else take from partition table (0x80 : default; 0x00 : always use DL; 0xFF : always use table entry)
|
1 | |
0x000D (13)
|
Reserved (default: 0x000000 )
|
3 | |
0x0010 (16)
|
LBA of LOADER boot sector or image file (optional; 0x00000000 if not used)
|
4 | |
0x0014 (20)
|
Patch offset of VBR boot unit (default 0x0000 if not used, else 0024hex or 01FDhex )
|
2 | |
0x0016 (22)
|
Checksum (0x0000 if not used)
|
2 | |
0x0018 (24)
|
OEM loader signature ("MSWIN4 " for in VBRs (optional)
|
6 | |
Varies | Bootstrap code area (code entry at 0x0000 )
|
Varies | |
0x01AC (428)
|
0x78
|
AAP signature (optional) | 2 |
0x01AD (429)
|
0x56
| ||
0x01AE (430)
|
AAP partition entry №0 with special semantics | AAP record (optional) | 16 |
0x01BE (446)
|
Partition entry №1 | Partition table (for primary partitions) |
16 |
0x01CE (462)
|
Partition entry №2 | 16 | |
0x01DE (478)
|
Partition entry №3 | 16 | |
0x01EE (494)
|
Partition entry №4 | 16 | |
0x01FE (510)
|
0x55
|
Boot signature[a] | 2 |
0x01FF (511)
|
0xAA
| ||
Total size: 30 + 398 + 2 + 16 + 4×16 + 2 | 512 |
Address | Description | Size (bytes) | |
---|---|---|---|
0x0000 (0) |
Bootstrap code area | 380 | |
0x017C (380)
|
0x5A
|
AST/NEC signature (optional; not for SpeedStor) | 2 |
0x017D (381)
|
0xA5
| ||
0x017E (382)
|
Partition entry №8 | AST/NEC expanded partition table (optional; also for SpeedStor) |
16 |
0x018E (398)
|
Partition entry №7 | 16 | |
0x019E (414)
|
Partition entry №6 | 16 | |
0x01AE (430)
|
Partition entry №5 | 16 | |
0x01BE (446)
|
Partition entry №4 | Partition table (for primary partitions) |
16 |
0x01CE (462)
|
Partition entry №3 | 16 | |
0x01DE (478)
|
Partition entry №2 | 16 | |
0x01EE (494)
|
Partition entry №1 | 16 | |
0x01FE (510)
|
0x55
|
Boot signature[a] | 2 |
0x01FF (511)
|
0xAA
| ||
Total size: 380 + 2 + 4×16 + 4×16 + 2 | 512 |
Address | Description | Size (bytes) | |
---|---|---|---|
0x0000 (0) |
Bootstrap code area | 252 | |
0x00FC (252)
|
0xAA
|
DM signature (optional) | 2 |
0x00FD (253)
|
0x55
| ||
0x00FE (254)
|
Partition entry | DM expanded partition table (optional) |
16 |
0x010E (270)
|
Partition entry | 16 | |
0x011E (286)
|
Partition entry | 16 | |
0x012E (302)
|
Partition entry | 16 | |
0x013E (318)
|
Partition entry | 16 | |
0x014E (334)
|
Partition entry | 16 | |
0x015E (350)
|
Partition entry | 16 | |
0x016E (366)
|
Partition entry | 16 | |
0x017E (382)
|
Partition entry | 16 | |
0x018E (398)
|
Partition entry | 16 | |
0x019E (414)
|
Partition entry | 16 | |
0x01AE (430)
|
Partition entry | 16 | |
0x01BE (446)
|
Partition entry №1 | Partition table (for primary partitions) |
16 |
0x01CE (462)
|
Partition entry №2 | 16 | |
0x01DE (478)
|
Partition entry №3 | 16 | |
0x01EE (494)
|
Partition entry №4 | 16 | |
0x01FE (510)
|
0x55
|
Boot signature[a] | 2 |
0x01FF (511)
|
0xAA
| ||
Total size: 252 + 2 + 12×16 + 4×16 + 2 | 512 |
Partition table entries
Offset (bytes) |
Field length |
Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0x00 | 1 byte | Status or physical drive (bit 7 set is for active or bootable, old MBRs only accept 0x80, 0x00 means inactive, and 0x01–0x7F stand for invalid)[c] | ||||||||||||||||||
0x01 | 3 bytes | CHS address of first absolute sector in partition.[d] The format is described by three bytes, see the next three rows. | ||||||||||||||||||
0x01 | 1 byte |
| ||||||||||||||||||
0x02 | 1 byte |
| ||||||||||||||||||
0x03 | 1 byte |
| ||||||||||||||||||
0x04 | 1 byte | Partition type[14] | ||||||||||||||||||
0x05 | 3 bytes | CHS address of last absolute sector in partition.[d] The format is described by 3 bytes, see the next 3 rows. | ||||||||||||||||||
0x05 | 1 byte |
| ||||||||||||||||||
0x06 | 1 byte |
| ||||||||||||||||||
0x07 | 1 byte |
| ||||||||||||||||||
0x08 | 4 bytes | LBA of first absolute sector in the partition[f] | ||||||||||||||||||
0x0C | 4 bytes | Number of sectors in partition[g] |
An artifact of hard disk technology from the era of the
In the CHS scheme, sector indices have (almost) always begun with sector 1 rather than sector 0 by convention, and due to an error in all versions of MS-DOS/PC DOS up to including 7.10, the number of heads is generally limited to 255
Due to the limits of CHS addressing,
Since block addresses and sizes are stored in the partition table of an MBR using 32 bits, the maximum size, as well as the highest start address, of a partition using drives that have 512-byte sectors (actual or emulated) cannot exceed 2 Alleviating this capacity limitation was one of the prime motivations for the development of the GPT.
Since partitioning information is stored in the MBR partition table using a beginning block address and a length, it may in theory be possible to define partitions in such a way that the allocated space for a disk with 512-byte sectors gives a total size approaching 4 TiB, if all but one partition are located below the 2 TiB limit and the last one is assigned as starting at or close to block 232−1 and specify the size as up to 232−1, thereby defining a partition that requires 33 rather than 32 bits for the sector address to be accessed. However, in practice, only certain LBA-48-enabled operating systems, including Linux, FreeBSD and Windows 7[18] that use 64-bit sector addresses internally actually support this. Due to code space constraints and the nature of the MBR partition table to only support 32 bits, boot sectors, even if enabled to support LBA-48 rather than LBA-28, often use 32-bit calculations, unless they are specifically designed to support the full address range of LBA-48 or are intended to run on 64-bit platforms only. Any boot code or operating system using 32-bit sector addresses internally would cause addresses to wrap around accessing this partition and thereby result in serious data corruption over all partitions.
For disks that present a sector size other than 512 bytes, such as
Where a data storage device has been partitioned with the GPT scheme, the master boot record will still contain a partition table, but its only purpose is to indicate the existence of the GPT and to prevent utility programs that understand only the MBR partition table scheme from creating any partitions in what they would otherwise see as free space on the disk, thereby accidentally erasing the GPT.
System bootstrapping
On
Since the BIOS bootstrap routine loads and runs exactly one sector from the physical disk, having the partition table in the MBR with the boot code simplifies the design of the MBR program. It contains a small program that loads the
Popular MBR code programs were created for booting
FDISK
partition table scheme to be in use and scans the list of partitions in the MBR's embedded partition table to find the only one that is marked with the active flag.[24] It then loads and runs the volume boot recordThere are alternative boot code implementations, some of which are installed by
On machines that do not use
There is some MBR replacement code that emulates EFI firmware's bootstrap, which makes non-EFI machines capable of booting from disks using the GPT partitioning scheme. It detects a GPT, places the processor in the correct operating mode, and loads the EFI compatible code from disk to complete this task.
Disk identity
In addition to the bootstrap code and a partition table, master boot records may contain a disk signature. This is a 32-bit value that is intended to identify uniquely the disk medium (as opposed to the disk unit—the two not necessarily being the same for removable hard disks).
The disk signature was introduced by Windows NT version 3.5, but it is now used by several operating systems, including the Linux kernel version 2.6 and later. Linux tools can use the NT disk signature to determine which disk the machine booted from.[27]
Windows NT (and later Microsoft operating systems) uses the disk signature as an index to all the partitions on any disk ever connected to the computer under that OS; these signatures are kept in
HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices\
If a disk's signature stored in the MBR was A8 E1 B9 D2 (in that order) and its first partition corresponded with logical drive C: under Windows, then the REG_BINARY
data under the key value \DosDevices\C:
would be:
A8 E1 B9 D2 00 7E 00 00 00 00 00 00
The first four bytes are said disk signature. (In other keys, these bytes may appear in reverse order from that found in the MBR sector.) These are followed by eight more bytes, forming a 64-bit integer, in
If this disk had another partition with the values 00 F8 93 71 02 following the disk signature (under, e.g., the key value \DosDevices\D:
), it would begin at byte offset 0x00027193F800 (10,495,457,280), which is also the first byte of physical sector 20,498,940.
Starting with
Programming considerations
The MBR originated in the
55 AA
.[a]The bootstrap sequence in the BIOS will load the first valid MBR that it finds into the computer's
The last instruction executed in the BIOS code will be a "jump" to that address in order to direct execution to the beginning of the MBR copy. The primary validation for most BIOSes is the signature at offset 0x01FE, although a BIOS implementer may choose to include other checks, such as verifying that the MBR contains a valid partition table without entries referring to sectors beyond the reported capacity of the disk.To the BIOS, removable (e.g. floppy) and fixed disks are essentially the same. For either, the BIOS reads the first physical sector of the media into RAM at absolute address 0x7C00, checks the signature in the last two bytes of the loaded sector, and then, if the correct signature is found, transfers control to the first byte of the sector with a jump (JMP) instruction. The only real distinction that the BIOS makes is that (by default, or if the boot order is not configurable) it attempts to boot from the first removable disk before trying to boot from the first fixed disk. From the perspective of the BIOS, the action of the MBR loading a volume boot record into RAM is exactly the same as the action of a floppy disk volume boot record loading the object code of an operating system loader into RAM. In either case, the program that the BIOS loaded is going about the work of chain loading an operating system.
While the MBR
The last 66 bytes of the 512-byte MBR are reserved for the partition table and other information, so the MBR boot sector program must be small enough to fit within 446 bytes of memory or less.
The MBR code examines the partition table, selects a suitable partition and loads the program that will perform the next stage of the boot process, usually by making use of INT 13h
The Status field in a partition table record is used to indicate an active partition. Standard-conformant MBRs will allow only one partition marked active and use this as part of a sanity-check to determine the existence of a valid partition table. They will display an error message, if more than one partition has been marked active. Some non-standard MBRs will not treat this as an error condition and just use the first marked partition in the row.
Traditionally, values other than 0x00 (not active) and 0x80 (active) were invalid and the bootstrap program would display an error message upon encountering them. However, the
BIOS to MBR interface
The MBR is loaded at memory location 0x0000:0x7C00 and with the following
.- IP= 0x0000:0x7C00 (fixed)
- Some Compaq BIOSes erroneously use 0x07C0:0x0000 instead. While this resolves to the same location in real mode memory, it is non-standard and should be avoided, since MBR code assuming certain register values or not written to be relocatable may not work otherwise.
- DL is supported by IBM BIOSes as well as most other BIOSes. The Toshiba T1000 BIOS is known not to support this properly, and some old Wyse 286 BIOSes use DL values greater or equal to 2 for fixed disks (thereby reflecting the logical drive numbers under DOS rather than the physical drive numbers of the BIOS). USB sticks configured as removable drives typically get an assignment of DL = 0x80, 0x81, etc. However, some rare BIOSes erroneously presented them under DL = 0x01, just as if they were configured as superfloppies.
- A standard conformant BIOS assigns numbers greater or equal to 0x80 exclusively to fixed disk / removable drives, and traditionally only values 0x80 and 0x00 were passed on as physical drive units during boot. By convention, only fixed disks / removable drives are partitioned, therefore, the only DL value a MBR could see traditionally was 0x80. Many MBRs were coded to ignore the DL value and work with a hard-wired value (normally 0x80), anyway.
- The This will also ensure compatibility with various non-standard assignments (see examples above), as far as the MBR code is concerned.
- Bootable CD-ROMs following the Host Protected Area(HPA). While designed to emulate floppies or superfloppies, MBR code accepting these non-standard DL values allows to use images of partitioned media at least in the boot stage of operating systems.
- INT 13h; else: don't care (should be zero). DH is supported by some IBM BIOSes.
- Some of the other registers may typically also hold certain register values (DS, ES, SS = 0x0000; SP = 0x0400) with original IBM ROM BIOSes, but this is nothing to rely on, as other BIOSes may use other values. For this reason, MBR code by IBM, Microsoft, Digital Research, etc. never did take any advantage of it. Relying on these register values in boot sectors may also cause problems in chain-boot scenarios.
Systems with
- DL = boot drive unit (see above)
- DI= points to "
$PnP
" installation check structure
- This information allows the boot loader in the MBR (or VBR, if passed on) to actively interact with the BIOS or a resident PnP / BBS BIOS overlay in memory in order to configure the boot order, etc., however, this information is ignored by most standard MBRs and VBRs. Ideally, ES:DI is passed on to the VBR for later use by the loaded operating system, but PnP-enabled operating systems typically also have fallback methods to retrieve the PnP BIOS entry point later on so that most operating systems do not rely on this.
MBR to VBR interface
By convention, a standard conformant MBR passes execution to a successfully loaded VBR, loaded at memory location 0x0000:0x7C00, by jumping to 0x0000:0x7C00 in the CPU's real mode with the following registers maintained or specifically set up:
- CS:IP = 0x0000:0x7C00[m] (constant)
- DL = boot drive unit (see above)
- MS-DOS 2.0–7.0 / PC DOS 2.0–6.3 MBRs do not pass on the DL value received on entry, but they rather use the boot status entry in the partition table entry of the selected primary partition as physical boot drive unit. Since this is, by convention, 0x80 in most MBR partition tables, it won't change things unless the BIOS attempted to boot off a physical device other than the first fixed disk / removable drive in the row. This is also the reason why these operating systems cannot boot off a second hard disk, etc. Some FDISK tools allow to mark partitions on secondary disks as "active" as well. In this situation, knowing that these operating systems cannot boot off other drives anyway, some of them continue to use the traditionally fixed value of 0x80 as active marker, whereas others use values corresponding with the currently assigned physical drive unit (0x81, 0x82), thereby allowing booting from other drives, at least in theory. In fact, this will work with many MBR codes, which take a set bit 7 of the boot status entry as active flag rather than insisting on 0x80, however, MS-DOS/PC DOS MBRs are hard-wired to accept the fixed value of 0x80 only. Storing the actual physical drive number in the partition table will also cause problems, when the BIOS assignment of physical drives changes, for example when drives are removed, added or swapped. Therefore, for a normal MBR accepting bit 7 as active flag and otherwise just using and passing on to the VBR the DL value originally provided by the BIOS allows for maximum flexibility. MS-DOS 7.1–8.0 MBRs have changed to treat bit 7 as active flag and any values 0x01..0x7F as invalid, but they still take the physical drive unit from the partition table rather than using the DL value provided by the BIOS. DR-DOS 7.07 extended MBRs treat bit 7 as active flag and use and pass on the BIOS DL value by default (including non-standard values 0x00..0x01 used by some BIOSes also for partitioned media), but they also provide a special )—this also allows other boot loaders to use NEWLDR as a chain-loader, configure its in-memory image on the fly and "tunnel" the loading of VBRs, EBRs, or AAPs through NEWLDR.
- The contents of DH and ES:DI should be preserved by the MBR for full Plug-and-Play support (see above), however, many MBRs, including those of MS-DOS 2.0–8.0 / PC DOS 2.0–6.3 and Windows NT/2000/XP, do not. (This is unsurprising, since those versions of DOS predate the Plug-and-Play BIOS standard, and previous standards and conventions indicated no requirements to preserve any register other than DL.) Some MBRs set DH to 0.
The MBR code passes additional information to the VBR in many implementations:
- DS:SI = points to the 16-byte Darwin bootloaders (Apple'sThis will cause problems if this assumption is incorrect. The MBR code of OS/2, MS-DOS 2.0 to 8.0, PC DOS 2.0 to 7.10 and Windows NT/2000/XP provides this same interface as well, although these systems do not use it. The Windows Vista/7 MBRs no longer provide this DS:SI pointer. While some extensions only depend on the 16-byte partition table entry itself, other extensions may require the whole 4 (or 5 entry) partition table to be present as well.
boot1h
,boot1u
, and David Elliott'sboot1fat32
) depend on this pointer as well, but additionally they don't use DS, but assume it to be set to 0x0000 instead.[33] - DS:MBR partition tableentry (in the relocated MBR) corresponding with the activated VBR. This is identical to the pointer provided by DS:SI (see above) and is provided by MS-DOS 2.0–8.0, PC DOS 2.0–7.10, Windows NT/2000/XP/Vista/7 MBRs. It is, however, not supported by most third-party MBRs.
Under DR-DOS 7.07 an extended interface may be optionally provided by the extended MBR and in conjunction with LOADER:
- AX= magic signature indicating the presence of this NEWLDR extension (0x0EDC)
- DL = boot drive unit (see above)
- DS:SI = points to the 16-byte MBR partition tableentry used (see above)
- ES:BX= start of boot sector or NEWLDR sector image (typically 0x7C00)
- CX= reserved
In conjunction with GPT, an
- EAX= 0x54504721 ("
!GPT
") - DL = boot drive unit (see above)
- DS:SI = points to a Hybrid MBR handover structure, consisting of a 16-byte dummy MBR partition table entry (with all bits set except for the boot flag at offset 0x00 and the partition typeat offset 0x04) followed by additional data. This is partially compatible with the older DS:SI extension discussed above, if only the 16-byte partition entry, not the whole partition table is required by these older extensions.
- Since older operating systems (including their VBRs) do not support this extension nor are they able to address sectors beyond the 2 TiB barrier, a GPT-enabled hybrid boot loader should still emulate the 16-byte dummy MBR partition table entry if the boot partition is located within the first 2 TiB.[n]
- ES:DI = points to "
$PnP
" installation check structure (see above)
Editing and replacing contents
Though it is possible to manipulate the
BOOTREC /FIXMBR
command.
Some third-party utilities may also be used for directly editing the contents of partition tables (without requiring any knowledge of hexadecimal or disk/sector editors), such as MBRWizard.[o]
dd
is a POSIX command commonly used to read or write any location on a storage device, MBR included. In
grub-install
and lilo -mbr
. The GRUB Legacy interactive console can write to the MBR, using the setup
and embed
commands, but GRUB2 currently requires grub-install
to be run from within an operating system.
Various programs are able to create a "backup" of both the primary partition table and the logical partitions in the extended partition.
Linux sfdisk
(on a
sfdisk -d /dev/hda > hda.out
and to restore is sfdisk /dev/hda < hda.out
. It is possible to copy the partition table from one disk to another this way, useful for setting up mirroring, but sfdisk executes the command without prompting/warnings using sfdisk -d /dev/sda | sfdisk /dev/sdb
.[39]See also
- Extended boot record (EBR)
- Volume boot record (VBR)
- GUID Partition Table (GPT)
- BIOS Boot partition
- EFI System partition
- Boot engineering extension record(BEER)
- Host protected area (HPA)
- Device configuration overlay (DCO)
- Apple partition map(APM)
- Amiga rigid disk block (RDB)
- Volume Table of Contents (VTOC)
- BSD disklabel
- Boot loader
- Disk cloning
- Recovery disc
- GNU Parted
- Partition alignment
Notes
- ^ big-endianrepresentation. Since this has been mixed up numerous times in books and even in original Microsoft reference documents, this article uses the offset-based byte-wise on-disk representation to avoid any possible misinterpretation.
- ^ In order to ensure the integrity of the MBR boot loader code, it is important that the bytes at 0x00DA to 0x00DF are never changed, unless either all six bytes represent a value of 0 or the whole MBR bootstrap loader code (except for the (extended) partition table) is replaced at the same time as well. This includes resetting these values to
00 00 00 00 00 00hex
unless the code stored in the MBR is known. Windows adheres to this rule. - ^ Originally, status values other than 0x00 and 0x80 were invalid, but modern MBRs treat the bit 7 as active flag and use this entry to store the physical boot unit.
- ^ a b The starting sector fields are limited to 1023+1 cylinders, 255+1 heads, and 63 sectors; ending sector fields have the same limitations.
- ^ a b c d e The range for sector is 1 through 63; the range for cylinder is 0 through 1023; the range for head is 0 through 255 inclusive.[13]
- ^ This entry is used by operating systems in certain circumstances; in such cases the CHS addresses are ignored.[15]
- ^ Zero is reserved and must not be used in normal partition entries. This entry is used by operating systems in certain circumstances; in such cases the CHS addresses are ignored.[15]
- ^ The address
0000hex
:7C00hex
is the first byte of the 32nd KB of RAM. The loading of the boot program at this address historically was the reason why, while the minimum RAM size of an original IBM PC (type 5150) was 16 KB, 32 KB were required for the disk option in the IBM XT. - ^ If there is an EBDA, the available memory ends below it.
- ^ Very old machines may have less than 640 KB (
A0000hex
or 655,360 bytes) of memory. In theory, only 32 KB (up to0000hex
:7FFFhex
) or 64 KB (up to0000hex
:FFFFhex
) are guaranteed to exist; this would be the case on an IBM XT-class machine equipped with only the required minimum amount of memory for a disk system. - ^ This applies when the BIOS handles a VBR, which is when it is in the first physical sector of unpartitioned media. Otherwise, the BIOS has nothing to do with the VBR. The design of VBRs is such as it is because VBRs originated solely on unpartitioned floppy disk media—the type 5150 IBM PC originally had no hard disk option—and the partitioning system using an MBR was later developed as an adaptation to put more than one volume, each beginning with its own VBR as-already-defined, onto a single fixed disk. By this design, essentially the MBR emulates the BIOS boot routine, doing the same things the BIOS would do to process this VBR and set up the initial operating environment for it just as if the BIOS had found that VBR on an unpartitioned medium.
- ^ IP is set as a result of the jump. CS may be set to 0 either by executing a far jump or by loading the register value explicitly before executing a near jump. (It is impossible for jumped-to x86 code to detect whether a near or far jump was used to reach it [unless the code that made the jump separately passes this information in some way].)
- ^ This is not part of the above mentioned proposal, but a natural consequence of pre-existing conditions.
- ^ For example, PowerQuest's Partition Table Editor (PTEDIT32.EXE), which runs under Windows operating systems, is still available here: Symantec's FTP site.
References
- ^ a b c d "Windows support for hard disks that are larger than 2 TB". 1. Microsoft. 2013-06-26. 2581408. Archived from the original on 2017-04-27. Retrieved 2013-08-28.
- ^ a b c Sedory, Daniel B. (2004). "The Mystery Bytes (or the Drive/Timestamp Bytes) of the MS-Windows 95B, 98, 98SE and Me Master Boot Record (MBR)". Master Boot Records. thestarman.pcministry.com. Archived from the original on 2017-08-24. Retrieved 2012-08-25.
- ISBN 9781886411999. Retrieved 2011-04-09.
Every operating system includes tools to manage MBR partitions. Unfortunately, every operating system handles MBR partitions in a slightly different manner.
- ISBN 0-672-32289-7.
- ISBN 1-4018-5230-0.
- ISBN 1-59200-112-2.
- ISBN 0-7357-1158-5.
- ISBN 0-7897-2283-6.
- Brouwer, Andries Evert (2004-04-22) [2000]. "Properties of partition tables". Partition types. Archived from the original on 2017-08-24. Retrieved 2017-08-24.[uses] a special fifth partition entry in front of the other four entries in the MBR and corresponding AAP-aware MBR bootstrap code. […]"
Matthias [R.] Paul writes: "[…] PTS-DOS
- Brouwer, Andries Evert (2004-04-22) [2000]. "Properties of partition tables". Partition types. Archived from the original on 2017-08-24. Retrieved 2017-08-24.MS-DOS partition tables with eight entries are preceded with a signature
Some OEM systems, such as AST DOS (type
(NB. NEC MS-DOS 3.30 and AST14hex
) and NEC DOS (type24hex
) had 8 instead of 4 partition entries in their MBR sectors. (Matthias R. Paul).A55Ahex
at offset 0x017C.) - ^ Sedory, Daniel B. (2007-05-18) [2003]. "Notes on the Differences in one OEM version of the DOS 3.30 MBR". Master Boot Records. Archived from the original on 2017-08-24. Retrieved 2017-08-24.
When we added partitions to this NEC table, the first one was placed at offsets 0x01EE through 0x01FD and the next entry was added just above it. So, the entries are inserted and listed backwards from that of a normal Table. Thus, looking at such a Table with a disk editor or partition listing utility, it would show the first entry in a NEC eight-entry table as being the last one (fourth entry) in a normal Partition Table.
(NB. Shows an 8-entry partition table and where its boot code differs from MS-DOS 3.30.) - ^ "Partition Table". osdev.org. 2017-03-18 [2007-03-06]. Archived from the original on 2017-08-24. Retrieved 2017-08-24.
- ^ ISBN 0-201-51806-6.
- Brouwer, Andries Evert (2013) [1995]. "List of partition identifiers for PCs". Partition types. Archivedfrom the original on 2017-08-24. Retrieved 2017-08-24.
- ^ ISBN 978-0-73561796-4.
- ^ "An Introduction to Hard Disk Geometry". Tech Juice. 2012-12-06 [2011-08-08]. Archived from the original on 2013-02-04.
- ^ Kozierok, Charles M. (2001-04-17). "BIOS and the Hard Disk". The PC Guide. Archived from the original on 2017-06-17. Retrieved 2013-04-19.
- ^ Smith, Robert (2011-06-26). "Working Around MBR's Limitations". GPT fdisk Tutorial. Archived from the original on 2017-08-24. Retrieved 2013-04-20.
- ^ "More than 2 TiB on a MBR disk". superuser.com. 2013-03-07. Archived from the original on 2017-08-24. Retrieved 2013-10-22.
- ^ "Transition to Advanced Format 4K Sector Hard Drives". Tech Insight. Seagate Technology. 2012. Archived from the original on 2017-08-24. Retrieved 2013-04-19.
- ^ Calvert, Kelvin (2011-03-16). "WD AV‐GP Large Capacity Hard Drives" (PDF). Western Digital. Retrieved 2013-04-20.
- ^ Smith, Roderick W. (2010-04-27). "Linux on 4KB-sector disks: Practical advice". DeveloperWorks. IBM. Archived from the original on 2017-08-24. Retrieved 2013-04-19.
- ^ a b "MBR (x86)". OSDev Wiki. OSDev.org. 2012-03-05. Archived from the original on 2017-08-24. Retrieved 2013-04-20.
- ^ Sedory, Daniel B. (2003-07-30). "IBM DOS 2.00 Master Boot Record". The Starman's Realm. Archived from the original on 2017-08-24. Retrieved 2011-07-22.
- ^ Singh, Amit (2009-12-25) [December 2003]. "Booting Mac OS X". Mac OS X Internals: The Book. Retrieved 2011-07-22.
- ^ de Boyne Pollard, Jonathan (2011-07-10). "The EFI boot process". Frequently Given Answers. Archived from the original on 2017-08-24. Retrieved 2011-07-22.
- ^ Domsch, Matt (2005-03-22) [2003-12-19]. "Re: RFC 2.6.0 EDD enhancements". Linux Kernel Mailing List. Archived from the original on 2017-08-24. Retrieved 2017-08-24.
- ^ "Windows may use Signature() syntax in the BOOT.INI file". KnowledgeBase. Microsoft.
- ^ McTavish (February 2014). "Vista's MBR Disk Signature". Multibooters: Dual and Multibooting with Vista. Archived from the original on 2017-08-24. Retrieved 2017-08-24.
- ^ Russinovich, Mark (2011-11-08). "Fixing Disk Signature Collisions". Mark Russinovich's Blog. Microsoft. Archived from the original on 2017-08-24. Retrieved 2013-04-19.
- ^ a b c Sakamoto, Masahiko (2010-05-13). "Why BIOS loads MBR into
0x7C00
in x86?". Glamenv-Septzen.net. Archived from the original on 2017-08-24. Retrieved 2011-05-04. - ^ Intel Corporation (1996-01-11). "BIOS Boot Specification 1.01" (PDF). 1.01. ACPICA. Archived (PDF) from the original on 2017-08-24. Retrieved 2013-04-20. [1]
- ^ a b Elliott, David F. (2009-10-12). "Why does the "standard" MBR set SI?". tgwbd.org. Archived from the original on 2017-08-24. Retrieved 2013-04-20.
- ^ Intel Corporation (1994-05-05). "Plug and Play BIOS Specification 1.0A" (PDF). 1.0A. Intel. Archived from the original(PDF) on 2017-08-24. Retrieved 2013-04-20.
- ^ Paul, Matthias R. (1997-10-02) [1997-09-29]. "Caldera OpenDOS 7.01/7.02 Update Alpha 3 IBMBIO.COM - README.TXT and BOOT.TXT - A short description of how OpenDOS is booted". Archived from the original on 2003-10-04. Retrieved 2009-03-29. [2]
- ^ Paul, Matthias R. (2017-08-14) [2017-08-07]. "The continuing saga of Windows 3.1 in enhanced mode on OmniBook 300". MoHPC - the Museum of HP Calculators. Archived from the original on 2018-05-01. Retrieved 2018-05-01.
[…] SYS […] /O[:nnn] Override IPL reported boot drive unit (n=0..126, 128..254). […] Preparing target disk... Choosing FAT12 CHS Boot Sector (requires IPL to report boot unit). Treating target as diskette or superfloppy medium (boot drive unit 0). Writing new Boot Sector... […]
(NB. SYS writes volume boot records rather than master boot records, but their incoming register interface is similar (with extensions) since they could both be loaded initially by the underlying system.) - Hewlett Packard, T13 Technical Committee. e09127r3. Archived(PDF) from the original on 2017-08-24. Retrieved 2013-04-20.
- ^ "FDISK /MBR rewrites the Master Boot Record". Support. 1. Microsoft. 2011-09-23. 69013. Archived from the original on 2017-02-08. Retrieved 2013-04-19.
- ^ "sfdisk(8) – Linux man page". die.net. 2013 [2007]. Archived from the original on 2017-08-24. Retrieved 2013-04-20.
- Brown, Ralf D. (2000-07-16). "Ralf Browns Interrupt List (v61 html)". Delorie Software. Retrieved 2016-11-03.
- Brown, Ralf D. (2000-07-16). "B-1302: INT 13 - DISK - READ SECTOR(S) INTO MEMORY". Ralf Brown's Interrupt List(RBIL) (61 ed.). Retrieved 2016-11-03. (NB. See file INTERRUP.B inside archive "INTER61A.ZIP.)
Further reading
- Gilbert, Howard (1996-01-01) [1995]. "Partitions and Volumes". PC Lube & Tune. Archived from the original on 2016-03-03.
- Knights, Ray (2004-12-22) [2000-12-16]. "Ray's Place". MBR and Windows Boot Sectors (includes code disassembly and explanations of boot process). Archived from the original on 2017-08-24. Retrieved 2017-08-24.
- Landis, Hale (2002-05-06). "Master Boot Record". How It Works. Archived from the original on 2014-07-01.
- Sedory, Daniel B. (2015-06-25) [2007]. "MBRs (Master Boot Records)". Boot Records Revealed. Archived from the original on 2017-08-24. Retrieved 2017-08-24. [3] [4]