Master boot record

From Wikipedia, the free encyclopedia - View original article

Jump to: navigation, search

A Master Boot Record (MBR) is a special type of boot sector at the very beginning of partitioned computer mass storage devices like fixed disks or removable drives intended for use with IBM PC-compatible systems and beyond. The MBR holds the information on how the logical partitions, containing file systems, are organized on that medium. Besides that, the MBR functions as an operating system independent chain boot loader in conjunction with each partition's Volume Boot Record (VBR).

MBRs are not present on non-partitioned media like floppies, superfloppies or other storage devices configured to behave as such.

The concept of MBRs was introduced in 1983. With storage volumes now commonly exceeding 2 TB, it has become a limiting factor in the 2010s. The MBR partitioning scheme is therefore in the process of being superseded by the GUID Partition Table (GPT) scheme in new computers. A GPT can coexist with a MBR in order to provide some limited form of backward compatibility for older systems.



Support for partitioned media, and thereby the Master Boot Record (MBR), was introduced with IBM PC DOS 2.0 in March 1983 in order to support the 10 MB hard disk of the then-new IBM Personal Computer XT, still using the FAT12 file system. The original version of the MBR was written by David Litton of IBM in 1982. The partition table supported up to four primary partitions, of which DOS could only use one. This did not change when FAT16 was introduced as a new file system with DOS 3.0. Support for an extended partition, a special primary partition type used as a container to hold other partitions, was added with DOS 3.2 and nested logical drives inside an extended partition came with DOS 3.30. Since MS-DOS, PC DOS, OS/2 and Windows were never enabled to boot off them, the MBR format and boot code remained almost unchanged in functionality, except for in some third-party implementations, throughout the DOS and OS/2 eras up to 1996, when support for Logical Block Addressing (LBA) (for disks larger than 8 GB) and disk timestamps was introduced with Windows 95B / DOS 7.10. This also reflects the fact, that the MBR is meant to be operating system and file system independent, although this design rule was partially compromised in more recent Microsoft implementations of the MBR, which enforce CHS access for FAT16B and FAT32 partition types whereas they use LBA for the FAT16X and FAT32X partition types.

Despite sometimes poor documentation of certain intrinsical details of the MBR format (which occasionally can cause compatibility problems), it was widely adopted as a de-facto industry standard due to the broad popularity of PC-compatible computers and its semi-static nature over decades, to the extent of being supported by computer operating systems for other platforms, sometimes in addition to other pre-existing or cross-platform standards for bootstrapping and partitioning.[1]

MBR partition entries and the MBR boot code used in commercial operating systems, however, are limited to 32 bits. Therefore, the maximum disk size supported by the MBR partitioning scheme (without using non-standard methods) is limited to 2 TB. 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 partitioning scheme (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 not enabled to support the GPT scheme as well. In the 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 TB 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 can cause various compatibility problems in certain scenarios, though.

The MBR consists of 512 or more bytes located in the first sector of the drive.

It may contain one or more of:

Disk partitioning

IBM PC DOS 2.0 introduced the FDISK utility to set up and maintain MBR partitions. When a storage device has been partitioned according to this scheme, its MBR contains a partition table describing the locations, sizes, and other attributes of linear regions referred to as partitions.

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.[7]

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 Volume Boot Record instead.) In cases where the computer is running a DDO BIOS overlay or boot manager, the partition table may be moved to some other physical location on the device; e.g., Ontrack Disk Manager often placed a copy of the original MBR contents in the second sector, then hid itself from any subsequently booted OS or application, so the MBR copy was treated as if it were still residing in the first sector.

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 PTS-DOS 6.60[8] and DR-DOS 7.07), eight (AST and NEC MS-DOS 3.x[9][10] as well as Storage Dimensions SpeedStor), or even sixteen entries (with Ontrack Disk Manager).

Structure of a classical generic MBR
AddressDescriptionSize in bytes
+000h+0Bootstrap code area446
+1BEh+446Partition entry #1Partition table
(for primary partitions)
+1CEh+462Partition entry #216
+1DEh+478Partition entry #316
+1EEh+494Partition entry #416
+1FEh+51055hBoot signature[nb 1]2
Total size: 446 + 4*16 + 2512

Structure of a modern standard MBR
AddressDescriptionSize in bytes
+000h+0Bootstrap code area (part 1)218
+0DAh+2180000hDisk timestamp[2][nb 2] (optional, MS-DOS 7.1-8.0 (Windows 95B/98/98SE/ME), alternatively can serve as OEM loader signature with NEWLDR)2
+0DCh+220original physical drive (80h-FFh)1
+0DDh+221seconds (0-59)1
+0DEh+222minutes (0-59)1
+0DFh+223hours (0-23)1
+0E0h+224Bootstrap code area (part 2, code entry at +000h)216
(or 222)
+1B8h+44032-bit disk signatureDisk signature (optional, UEFI, Windows NT/2000/Vista/7 and other OSes)4
+1BEh+446Partition entry #1Partition table
(for primary partitions)
+1CEh+462Partition entry #216
+1DEh+478Partition entry #316
+1EEh+494Partition entry #416
+1FEh+51055hBoot signature[nb 1]2
Total size: 218 + 6 + 216 + 6 + 4*16 + 2512

Structure of AAP MBR
AddressDescriptionSize in bytes
+000h+0Bootstrap code area428
+1ACh+42878hAAP signature (optional)2
+1AEh+430AAP physical drive (80h-FEh; 00h: not used; 01h-7Fh, FFh: reserved)AAP record (optional) (AAP partition entry #0 with special semantics)1
+1AFh+431CHS (start) address of AAP partition/image file or VBR/EBR3
+1B2h+434Reserved for AAP partition type (00h if not used) (optional)1
+1B3h+435Reserved for CHS end address in AAP (optional; byte at offset +1B5h is also used for MBR checksum (PTS DE, BootWizard); 000000h if not used)3
+1B6h+438Start LBA of AAP image file or VBR/EBR or relative sectors of AAP partition (copied to offset +01Ch in the loaded sector over the "hidden sectors" entry of a DOS 3.31 BPB (or emulation thereof) to also support EBR booting)4
+1BAh+442Reserved for sectors in AAP (optional; 00000000h if not used)4
+1BEh+446Partition entry #1Partition table
(for primary partitions)
+1CEh+462Partition entry #216
+1DEh+478Partition entry #316
+1EEh+494Partition entry #416
+1FEh+51055hBoot signature[nb 1]2
Total size: 428 + 2 + 16 + 4*16 + 2512

Structure of NEWLDR MBR
AddressDescriptionSize in bytes
+000h+0JMPS (EBh) / NEWLDR record size (often 0Ah/16h/1Ch for code start at +00Ch/+018h/+01Eh)NEWLDR record (optional)2
+002h+2"NEWLDR" signature6
+008h+8LOADER physical drive and boot flag (80h-FEh, 00h-7Eh, FFh, 7Fh) (if not used, this and following 3 bytes must be all 0)1
+009h+9CHS address of LOADER boot sector or image file (f.e. IBMBIO.LDR) (000000h if not used)3
+00Ch+12allowed DL minimum, else take from partition table (80h: default; 00h: always use DL; FFh: always use table entry)1
+00Dh+13reserved (default: 000000h)3
+010h+16LBA of LOADER boot sector or image file (optional, 00000000h if not used)4
+014h+20patch offset of VBR boot unit (default 0000h if not used, else 0024h or 01FDh)2
+016h+22checksum (0000h if not used)2
+018h+24OEM loader signature ("MSWIN4" for REAL/32, see also offset +0DAh, corresponds with OEM label at offset +003h in VBRs (optional)6
variesvariesBootstrap code area (code entry at +000h)varies
+1ACh+42878hAAP signature (optional)2
+1AEh+430AAP partition entry #0 with special semanticsAAP record (optional)16
+1BEh+446Partition entry #1Partition table
(for primary partitions)
+1CEh+462Partition entry #216
+1DEh+478Partition entry #316
+1EEh+494Partition entry #416
+1FEh+51055hBoot signature[nb 1]2
Total size: 30 + 398 + 2 + 16 + 4*16 + 2512

Structure of AST/NEC MS-DOS and SpeedStor MBR
AddressDescriptionSize in bytes
+000h+0Bootstrap code area380
+17Ch+3805AhAST/NEC signature (optional, not for SpeedStor)2
+17Eh+382Partition entry #8AST/NEC expanded partition table
(optional, also for SpeedStor)
+18Eh+398Partition entry #716
+19Eh+414Partition entry #616
+1AEh+430Partition entry #516
+1BEh+446Partition entry #4Partition table
(for primary partitions)
+1CEh+462Partition entry #316
+1DEh+478Partition entry #216
+1EEh+494Partition entry #116
+1FEh+51055hBoot signature[nb 1]2
Total size: 380 + 2 + 4*16 + 4*16 + 2512

Structure of Disk Manager MBR
AddressDescriptionSize in bytes
+000h+0Bootstrap code area252
+0FCh+252AAhDM signature (optional)2
+0FEh+254Partition entryDM expanded partition table
+10Eh+270Partition entry16
+11Eh+286Partition entry16
+12Eh+302Partition entry16
+13Eh+318Partition entry16
+14Eh+334Partition entry16
+15Eh+350Partition entry16
+16Eh+366Partition entry16
+17Eh+382Partition entry16
+18Eh+398Partition entry16
+19Eh+414Partition entry16
+1AEh+430Partition entry16
+1BEh+446Partition entry #1Partition table
(for primary partitions)
+1CEh+462Partition entry #216
+1DEh+478Partition entry #316
+1EEh+494Partition entry #416
+1FEh+51055hBoot signature[nb 1]2
Total size: 252 + 2 + 12*16 + 4*16 + 2512

Partition table entries

Layout of one 16-byte partition entry (all multi-byte fields are little-endian)
+0h1status / physical drive (bit 7 set: active / bootable, old MBRs only accept 80h), 00h: inactive, 01h-7Fh: invalid)[a]
+1h3CHS address of first absolute sector in partition.[b] The format is described by 3 bytes, see the next 3 rows.
h7-0head [c]
c9‑8s5–0sector in bits 5–0; bits 7–6 are high bits of cylinder[c]
c7-0bits 7–0 of cylinder[c]
+4h1Partition type[11]
+5h3CHS address of last absolute sector in partition.[b] The format is described by 3 bytes, see the next 3 rows.
c9‑8s5–0sector in bits 5–0; bits 7–6 are high bits of cylinder[c]
c7-0bits 7–0 of cylinder
+8h4LBA of first absolute sector in the partition[d]
+Ch4Number of sectors in partition[d]

^ a Originally, status values other than 00h and 80h were invalid, but modern MBRs treat bit 7 as active flag and use this entry to store the physical boot unit (see below).

^ b Starting Sector fields are limited to 1023+1 cylinders, 255+1 heads, and 63 sectors; Ending Sector fields have the same limitations.

^ c 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.[12]

^ d Used by OSes in certain circumstances; in such cases the CHS addresses are ignored.[13]

An artifact of hard disk technology from the era of the PC XT, the partition table subdivides a storage medium using units of cylinders, heads, and sectors (CHS addressing). These values no longer correspond to their namesakes in modern disk drives, as well as being irrelevant in other devices such as solid-state drives which do not physically have cylinders or heads.

In the CHS scheme, sector indices have 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 are generally limited to 255[citation needed] instead of 256. When a CHS address is too large to fit into these fields, the tuple (1023, 254, 63) is typically used today, although on older systems, and with older disk tools, the cylinder value often wrapped around modulo the CHS 8 GB barrier, causing ambiguity and risks of data corruption. (If the situation involves a "protective" MBR on a disk with a GPT, Intel's Extensible Firmware Interface specification requires that the tuple (1023, 255, 63) be used.) The 10-bit cylinder value is recorded within two bytes in order to facilitate making calls to the original/legacy INT 13h BIOS disk access routines, where 16 bits were divided into sector and cylinder parts, and not on byte boundaries.[12]

Due to the limits of CHS addressing,[14][15] a transition was made to using LBA or Logical Block Addressing. Both the partition length and partition start address are sector values stored in the partition table entries as 32-bit quantities. The sector size used to be considered fixed at 512 (29) bytes, and a broad range of important components including chipsets, operating systems, database engines, partitioning tools, backup and file system utilities and other software had this value hard-coded. Since the end of 2009, disk drives using a new technology known as Advanced Format and employing 4,096-byte sectors (4Kn) have been available, although the size of the sector for some of these drives was still reported as 512 bytes to the host system through conversion in the hard drive firmware and referred to as 512 emulation drives (512e).

Since block addresses and sizes are stored in the partition table of an MBR using 32 bits, the maximum size of a partition and the maximum start address using drives that have 512-byte sectors (actual or emulated) cannot exceed 2 TiB−512 bytes (2,199,023,255,040 bytes or 4,294,967,295 (232−1) sectors × 512 (29) bytes per sector). Alleviating this capacity limitation was one of the prime motivations for the development of the GUID partition table (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 two or more partitions such that the allocated space for a disk with 512-byte sectors gives a total size approaching 4 TiB, if the last partition is assigned as starting at or close to block 232−1 and specify the size as 232−1 (up to the limit of disk size). However, in practice, only certain LBA-48 enabled operating systems, including Linux, FreeBSD and Windows 7[16] that use 64-bit sector addresses internally actually support this. Any operating system using 32-bit sector addresses internally would cause addresses to wrap around and thereby result in serious data corruption.

For disks that present a sector size other than 512-bytes, there are limitations as well. A sector size of 4,096 results in an eight-fold increase in the size of a partition that can be defined using MBR, up to 16 TiB−4,096 bytes.[citation needed] Versions of Windows more recent than Windows XP support the larger sector sizes as well as Mac OS X, and the Linux kernel has supported larger sector sizes since 2.6.31[17] or 2.6.32,[18] but issues with boot loaders, partitioning tools and computer BIOS implementations present certain limitations.[19]

Where a data storage device has been partitioned with the GUID partition table (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 which 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 IBM PC-compatible computers, the bootstrapping firmware contained within the ROM BIOS loads and executes the master boot record.[20] The PC/XT (type 5160) used an Intel 8088 microprocessor. In order to remain compatible, all x86 architecture systems start with the microprocessor in an operating mode referred to as real mode. The BIOS reads the MBR from the storage device into physical memory, and then it directs the microprocessor to the start of the boot code. Since the BIOS runs in real mode, the processor is in real mode when the MBR program begins to execute, and so the beginning of the MBR is expected to contain real mode machine language instructions.[20]

Due to the restricted size of the MBR's code section, it typically contains only a small program that copies additional code (such as a boot loader) from the storage device into memory. Control is then passed to this code, which is responsible for loading the actual operating system. This process is known as chain loading.

Popular MBR code programs were created for booting PC DOS and MS-DOS, and similar boot code remains in wide use. These boot sectors expect the 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.[21] It then loads and runs the Volume Boot Record (VBR) of the active partition.

There are alternative boot code implementations, some of which are installed by boot managers, which operate in a variety of ways. Some MBR code loads additional code for a boot manager from the first track of the disk, which it assumes to be "free" space that is not allocated to any disk partition, and executes it. A MBR program may interact with the user to determine which partition on which drive should boot, and may transfer control to the MBR of a different drive. Other MBR code contains a list of disk locations (often corresponding to the contents of files in a filesystem) of the remainder of the boot manager code to load and to execute. (The first relies on behavior that is not universal across all disk partitioning utilities, most notably those which read and write GPTs. The last requires that the embedded list of disk locations be updated when changes are made that would relocate the remainder of the code.)

On machines that do not use x86 processors, or on x86 machines with non-BIOS firmware such as Open Firmware or Extensible Firmware Interface (EFI) firmware, this design is unsuitable, and the MBR is not used as part of the system bootstrap.[22] EFI firmware is instead capable of directly understanding the GPT partitioning scheme and the FAT filesystem format, and loads and runs programs held as files in the EFI System partition.[23] The MBR will be involved only insofar as it might contain a partition table for compatibility purposes if the GPT partition table scheme has been used.

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

Information contained in the Partition Table of an external hard drive as it appears in the utility program QtParted, running under Linux.

In addition to the bootstrap code and a partition table, master boot records may contain a Windows NT 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 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.[24]

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 registry keys, primarily for storing the persistent mappings between disk partitions and drive letters. It may also be used in BOOT.INI files (though most do not), to describe the location of bootable Windows NT (or later) partitions.[25] One key (among many) where NT disk signatures appear in a Windows 2000/XP registry is:


If a disk's signature stored in the MBR was A8h E1h B9h D2h (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:

 A8h E1h B9h D2h 00h 7Eh 00h 00h 00h 00h 00h 00h 

The first four bytes are said disk signature. (Note: 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 little endian notation, which are used to locate the byte offset of this partition. In this case, 00h 7Eh corresponds to the hexadecimal value 7E00h (32,256). If we assume the drive in question reports a sector size of 512 bytes, then dividing this byte offset by 512 results in 63, which is the physical sector number (or LBA) containing the first sector of the partition (unlike the sector count used in the sectors value of CHS tuples, which counts from one, the absolute or LBA sector value starts counting from zero).

If this disk had another partition with the values 00h F8h 93h 71h 02h following the disk signature (under, e.g., the key value \DosDevices\D:), it would begin at byte offset 00027193F800h (10,495,457,280), which is also the first byte of physical sector 20,498,940.

Starting with Windows Vista, the disk signature is also stored in the Boot Configuration Data (BCD) store and the boot process depends on it.[26] If the disk signature changes, cannot be found or has a conflict, Windows is unable to boot.[27] Unless Windows is forced to use the overlapping part of the LBA address of the Advanced Active Partition entry as pseudo-disk signature, Windows' usage is conflictive with the Advanced Active Partition feature of PTS-DOS 7 and DR-DOS 7.07, in particular if their boot code is located outside the first 8 GB of the disk, so that LBA addressing must be used.

Programming considerations

The MBR originated in the PC XT.[28] IBM PC-compatible computers are little-endian, which means numeric values spanning two or more bytes are stored by the processor in reverse order in memory. The format of the MBR on media reflects this convention. Thus, the MBR signature will appear in a disk editor as the sequence 55h AAh.[nb 1]

The bootstrap sequence in the BIOS will load the first valid MBR that it finds into the computer's physical memory at address 0000h:7C00h.[28] The last instruction executed in the BIOS code will be a "jump" to that address, to direct execution to the beginning of the MBR copy. The primary validation for most BIOSes is the signature at offset +1FEh, although a BIOS implementor 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.

While the MBR boot sector code expects to be loaded at physical address 0000h:7C00h, all the memory from physical address 0000h:0501h (address 0000h:0500h is the last one used by a Phoenix BIOS)[12] to 0000h:7FFFh (and sometimes up to 0000h:FFFFh) is available in real mode . The INT 12h BIOS interrupt call may help in determining how much memory can be allocated safely (it simply reads the base memory size in KiB from segment:offset location 0040h:0013h).

The last 72 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 440 bytes of memory. The MBR code may communicate with the user, examine the partition table. Eventually, the MBR will need to perform its main task, and load the program that will perform the next stage of the boot process, usually by making use of INT 13h BIOS calls.

As stated above, the conventional MBR bootstrap code loads and runs (boot loader or operating system dependent) Volume Boot Record code that is located at the beginning of the "active" partition. A conventional Volume Boot Record will fit within a 512-byte sector, but it is safe for MBR code to load additional sectors to accommodate boot loaders longer than one sector, provided they do not make any assumptions on what the sector size is. Like the MBR, a Volume Boot Record normally expects to be loaded at address 0000h:7C00h. Since this is the same location where the MBR is loaded, one of the first tasks of a MBR is to relocate itself somewhere else in memory —most often at 0000h:0600h (for MS-DOS/PC DOS, OS/2 and Windows MBR code) or 0060h:0000h (most DR-DOS MBRs). Even though this resolves to the same memory address in real mode, for Apple Darwin to boot, the MBR must be relocated to 0000h:0600h instead of 0060h:0000h, since the code depends on the DS:SI pointer to the partition entry provided by the MBR, but erroneously refers to it via 0000h:SI only.[29] While the MBR code relocates itself it is still important not to relocate to other addresses in memory because many VBRs will assume a certain standard memory layout when loading their boot file.

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 00h (not active) and 80h (active) were invalid and the bootstrap program would display an error message upon encountering them. However, the Plug and Play BIOS Specification and BIOS Boot Specification (BBS) allowed other devices to become bootable as well since 1994.[30][31] Consequently, with the introduction of MS-DOS 7.10 (Windows 95B) and higher, the MBR started to treat a set bit 7 as active flag and showed an error message for values 01h..7Fh only. It continued to treat the entry as physical drive unit to be used when loading the corresponding partition's VBR later on, thereby now also accepting other boot drives than 80h as valid, however, MS-DOS did not make use of this extension by itself. Storing the actual physical drive number in the partition table does not normally cause backward compatibility problems, since the value will differ from 80h only on drives other than the first one (which have not been bootable before, anyway). However, even with systems enabled to boot off other drives, the extension may still not work universally, for example, after the BIOS assignment of physical drives has changed, f.e. when drives are removed, added or swapped. Therefore, per the BIOS Boot Specification (BBS),[31] it is best practice for a modern MBR accepting bit 7 as active flag to pass on the DL value originally provided by the BIOS instead of using the entry in the partition table.

BIOS to MBR interface

The MBR is loaded at memory location 0000h:7C00h and with the following CPU registers set up when the prior bootstrap loader (normally the IPL in the BIOS) passes execution to it by jumping to 0000h:7C00h in the CPU's real mode.

Some Compaq BIOSes erroneously use 07C0h:0000h 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 relocatible may not work otherwise.
DL is supported by IBM BIOSes as well as most other BIOSes. The Toshiba T1000 BIOS is known to not 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 = 80h, 81h, etc. however, some rare BIOSes erroneously presented them under DL = 01h, just as if they were configured as superfloppies.
A standard conformant BIOS assigns numbers greater or equal to 80h exclusively to fixed disk / removable drives, and traditionally only values 80h and 00h 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 80h. Many MBRs were coded to ignore the DL value and work with a hard-wired value (normally 80h), anyway.
The Plug and Play BIOS Specification and BIOS Boot Specification (BBS) allow other devices to become bootable as well since 1994.[30][31] The later recommends that MBR and VBR code should use DL rather than internally hardwired defaults.[31] 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 El Torito specification may contain disk images mounted by the BIOS to occur as floppy or superfloppies on this interface. DL values of 00h and 01h may also be used by Protected Area Run Time Interface Extension Services (PARTIES) and Trusted Computing Group (TCG) BIOS extensions in Trusted mode to access otherwise invisible PARTIES partitions, disk image files located via the Boot Engineering Extension Record (BEER) in the last physical sector of a hard disk's 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.

Systems with Plug-and-Play BIOS or BBS support will provide a pointer to PnP data in addition to DL:[30][31]

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 0000h:7C00h, by jumping to 0000h:7C00h in the CPU's real mode with the following registers maintained or specifically set up:

MS-DOS 2.0-7.0 / PC DOS 2.0-6.3 MBRs do not pass on the DL value received on entry, but 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, 80h 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 80h as active marker, whereas others use values corresponding with the currently assigned physical drive unit (81h, 82h), thereby allowing to boot off 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 80h, however, MS-DOS/PC DOS MBRs are hard-wired to accept the fixed value of 80h only. Storing the actual physical drive number in the partiton table will also cause problems, when the BIOS assignment of physical drives changes, f.e. 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 01h..7Fh 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 00h..01h used by some BIOSes also for partitioned media), but they also provide a special NEWLDR configuration block in order to support alternative boot methods in conjunction with LOADER and REAL/32 as well as to change the detail behaviour of the MBR, so that it can also work with drive values retrieved from the partition table (important in conjunction with LOADER and AAPs, see NEWLDR offset +00Ch), translate Wyse non-standard drive units 02h..7Fh to 80h..FDh, and optionally fix up the drive value (stored at offset +19h in the Extended BIOS Parameter Block (EBPB) or at sector offset +1FDh) in loaded VBRs before passing execution to them (see NEWLDR offset +014h) — 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 MBR code passes additional information to the VBR in many implementations:

Under DR-DOS 7.07 an extended interface may be optionally provided by the extended MBR and in conjunction with LOADER:

In conjunction with GUID partition tables (GPT), an Enhanced Disk Drive Specification (EDD) 4 Hybrid MBR proposal recommends another extension to the interface:[32]

Since older operating systems (including their VBRs) do no support this extension nor are they able to address sectors beyond the 2 TB 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 TB.

Editing/replacing MBR contents

Though it is possible to manipulate the bytes in the MBR sector directly using various disk editors, there are tools to write fixed sets of functioning code to the MBR. Since MS-DOS 5.0, the program FDISK has included the switch /MBR, which will rewrite the MBR code.[33] Under Windows 2000 and Windows XP, the Recovery Console can be used to write new MBR code to a storage device using its fixmbr command. Under Windows Vista and Windows 7, the Recovery Environment can be used to write new MBR code using 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.[nb 3]

dd is also a commonly used POSIX command to read or write to any location on a storage device, MBR included. In Linux, ms-sys may be used to install a Windows MBR. The GRUB and LILO projects have tools for writing code to the MBR sector, namely 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 SystemRescueCD) is able to save a backup of the primary and extended partition table. It creates a file that can be read in a text editor, or this file can be used by sfdisk to restore the primary/extended partition table. An example command to back up the partition table is 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 it should be noted that sfdisk executes the command without prompting/warnings using sfdisk -d /dev/sda | sfdisk /dev/sdb.[34]

See also


  1. ^ a b c d e f g The signature at offset +1FEh in boot sectors is 55h AAh, that is 55h at offset +1FEh and AAh at offset +1FFh. Since little-endian representation must be assumed in the context of IBM PC compatible machines, this can be written as 16-bit word AA55h in programs for x86 processors (note the swapped order), whereas it would have to be written as 55AAh in programs for other CPU architectures using a big-endian representation. 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.
  2. ^ In order to ensure the integrity of the MBR boot loader code, it is important that the bytes at +0DAh to +0DFh 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 00h 00h 00h 00h 00h 00h unless the code stored in the MBR is known. Windows adheres to this rule.
  3. ^ For example, PowerQuest's Partition Table Editor (PTEDIT32.EXE), which runs under Windows operating systems, is still available here: Symantec's FTP site.


  1. ^ Michael Lucas (2003). Absolute OpenBSD: Unix for the practical paranoid. p. 73. 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."
  2. ^ a b Daniel B. Sedory (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. Retrieved 2012-08-25.
  3. ^ Peter Norton and Scott Clark (2002). Peter Norton's New Inside the PC. Sams Publishing. pp. 360–361. ISBN 0-672-32289-7.
  4. ^ Michael W. Graves (2004). A+ Guide To PC Hardware Maintenance and Repair. Thomson Delmar. p. 276. ISBN 1-4018-5230-0.
  5. ^ Jean Andrews (2003). Upgrade and Repair with Jean Andrews. Thomson Course Technology. p. 646. ISBN 1-59200-112-2.
  6. ^ William Boswell (2003). Inside Windows Server 2003. Addison-Wesley Professional. p. 13. ISBN 0-7357-1158-5.
  7. ^ Roderick W. Smith (2000). The Multi-Boot Configuration Handbook. Que Publishing. pp. 260–261. ISBN 0-7897-2283-6.
  8. ^ Andries Evert Brouwer. "Properties of partition tables". Partition types. Matthias Paul: "PTS-DOS [uses] a special fifth partition entry in front of the other four entries in the MBR and corresponding AAP-aware MBR bootstrap code."
  9. ^ Andries Evert Brouwer. "Properties of partition tables". Partition types. "Some OEM systems, such as AST DOS (type 14h) and NEC DOS (type 24h) had 8 instead of 4 partition entries in their MBR sectors. (Matthias Paul)." (NB. NEC MS-DOS 3.30 and AST MS-DOS partition tables with eight entries are preceded with a signature A55Ah at offset +17Ch.)
  10. ^ Daniel B. Sedory. "Notes on the Differences in one OEM version of the DOS 3.30 MBR". Master Boot Records. "When we added partitions to this NEC table, the first one was placed at offsets +1EEh through +1FDh 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." Shows an 8-entry partition table and where its boot code differs from MS-DOS 3.30.
  11. ^ Andries Evert Brouwer. "List of partition identifiers for PCs". Partition types.
  12. ^ a b c System BIOS for IBM PC/XT/AT Computers and Compatibles. Phoenix technical reference. Addison-Wesley. 1989. ISBN 0-201-51806-6.
  13. ^ [Microsoft (2000). Microsoft Windows 2000 Server Operations Guide, Microsoft Press. pp. 18.]
  14. ^
  15. ^
  16. ^ Robert Smith (2011-06-26,). Working Around MBR's Limitations. ([1]).
  17. ^ [2]
  18. ^ [3]
  19. ^ [4]
  20. ^ a b "MBR (x86) - OSDev Wiki". 2011-06-11. Retrieved 2011-07-22.
  21. ^ Daniel B. Sedory (2003-07-30). "IBM DOS 2.00 Master Boot Record". The Starman's Realm. Retrieved 2011-07-22.
  22. ^ Amit Singh (2009-12-25). "Booting Mac OS X". Mac OS X Internals: The Book. Retrieved 2011-07-22.
  23. ^ Jonathan de Boyne Pollard (2011-07-10). "FGA: The EFI boot process". Frequently Given Answers. Jonathan de Boyne Pollard. Retrieved 2011-07-22.
  24. ^ Matt Domsch. "Re: RFC 2.6.0 EDD enhancements". Linux Kernel Mailing List.
  25. ^ Microsoft. "Windows may use Signature() syntax in the BOOT.INI file". KnowledgeBase.
  26. ^ Vista's MBR Disk Signature
  27. ^ Fixing Disk Signature Collisions
  28. ^ a b Masahiko Sakamoto (2010-05-13). "Why BIOS loads MBR into 0x7C00 in x86?". Retrieved 2011-05-04.
  29. ^ a b David Elliott (2009). Why does the "standard" MBR set SI? Blog [5].
  30. ^ a b c Compaq Computer Corporation, Phoenix Technologies Ltd, Intel Corporation (1994-05-05). Plug and Play BIOS Specification 1.0A ([6]).
  31. ^ a b c d e Compaq Computer Corporation, Phoenix Technologies Ltd, Intel Corporation (1996-01-11). BIOS Boot Specification 1.01 ([7]).
  32. ^ Robert Elliott (2010-01-04). e09127r3 EDD-4 Hybrid MBR boot code annex. Hewlett Packard, T13 Technical Committee ([8]).
  33. ^
  34. ^ "sfdisk(8) - Linux man page".

Further reading

External links