Content deleted Content added
removed weasel word, clarified Tags: Mobile edit Mobile web edit |
|||
(29 intermediate revisions by 25 users not shown) | |||
Line 1:
{{Short description|First sector of a partitioned computer disk}}
{{About|
{{Use dmy dates|date=April 2019|cs1-dates=y}}
{{Use list-defined references|date=January 2022}}
A '''master boot record''' ('''MBR''') is a special type of [[boot sector]] at the very beginning of [[disk partitioning|partitioned]] computer [[mass storage device]]s like [[fixed disk]]s or [[removable drive]]s intended for use with [[IBM PC-compatible]] systems and beyond. The concept of MBRs was publicly introduced in 1983 with [[PC DOS 2.0]].▼
▲A '''master boot record''' ('''MBR''') is a
The MBR holds the information on how the logical partitions, containing file systems, are organized on that medium. 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.<ref name="FOLDOC"/>▼
▲The MBR holds the information on how the
The organization of the partition table in the MBR limits the maximum addressable storage space of a partitioned disk to 2 [[Tebibyte|TiB]] {{nowrap|(2<sup>32</sup> × 512 bytes)}}.<ref name="Microsoft_2013_2581408"/> Approaches to slightly raise this limit
MBRs are not present on non-partitioned media such as [[floppy|floppies]], [[superfloppy|superfloppies]] or other storage devices configured to behave as such, nor are they necessarily present on drives used in non-PC platforms.
== {{Anchor|DISK-TIMESTAMPS}}Overview ==
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 June 1982. The partition table supported up to four ''primary partitions''
In 1996, support for [[logical block addressing]] (LBA) was introduced in Windows 95B and MS-DOS 7.10 (Not to be confused with IBM PC-DOS 7.1) in order to support disks larger than 8 GB. ''Disk timestamps'' were also introduced.<ref name="Sedory_2004_Timestamp"/><!-- TBD: Recheck, if MBR LBA support was really added with 95B/7.1 only, since LBA support in general was added with 95A/7.0 in 1995 already IIRC. --> This also reflected the idea that the MBR is meant to be operating system and file system independent. However, this design rule was partially compromised in more recent Microsoft implementations of the MBR, which enforce [[cylinder-head-sector|CHS]] access for [[FAT16B]] and [[FAT32]] partition types [[Partition type#PID 06h|{{mono|0x06}}]]/[[Partition type#PID 0Bh|{{mono|0x0B}}]], whereas LBA is used for [[Partition type#PID 0Eh|{{mono|0x0E}}]]/[[Partition type#PID 0Ch|{{mono|0x0C}}]].
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 [[cross-platform]] standards for bootstrapping and partitioning.<ref name="Lucas_2003_OpenBSD"/>
MBR partition entries and the MBR boot code used in commercial operating systems, however, are limited to 32 bits.<ref name="Microsoft_2013_2581408"/> Therefore, the maximum disk size supported on disks using 512-byte sectors (whether real or emulated) by the MBR partitioning scheme (without
The MBR consists of 512 or more [[byte]]s located in the first [[disk sector|sector]] of the drive.
Line 176 ⟶ 178:
|-
| style="text-align:center" | {{anchor|MBRAAP_OFS_1AEh}}<code>0x01AE</code> (430)
| style="text-align:center; background:#F2F2F2" | AAP physical drive (<code>0x80</code>
| rowspan="6" style="vertical-align:middle; text-align:center; background:#F2F2F2" | ''AAP record'' (optional) (AAP [[#PTE|partition entry]] #0 with special semantics)
| style="text-align:center" | 1
Line 248 ⟶ 250:
|-
| style="text-align:center" | {{anchor|NEWLDR_OFS_008h}}<code>0x0008</code> (8)
| style="text-align:center; background:#F2F2F2" | LOADER physical drive and boot flag (<code>0x80</code>
| style="text-align:center" | 1
|-
Line 260 ⟶ 262:
|-
| style="text-align:center" | {{anchor|NEWLDR_OFS_00Dh}}<code>0x000D</code> (13)
| style="text-align:center; background:#F2F2F2" | Reserved (default: <code>0x000000</code>)<!-- Already used, but it is
| style="text-align:center" | 3
|-
Line 605 ⟶ 607:
|}
|-
| {{anchor|PTE_OFS_8h}}{{mono|0x08}} || || 4 bytes || [[logical block addressing|LBA]] of first absolute sector in the partition{{Efn|name="note-4"|
|-
| {{anchor|PTE_OFS_Ch}}{{mono|0x0C}} || || 4 bytes || Number of sectors in partition{{Efn|name="note-
|}
Line 618 ⟶ 620:
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 <abbr title="TebiByte = 1024×1024×1024×1024 byte">[[Tebibyte|TiB]]</abbr>−512 bytes ({{val|2199023255040}} bytes or {{val|4294967295}} (2<sup>32</sup>−1) sectors × 512 (2<sup>9</sup>) bytes per sector).<ref name="Microsoft_2013_2581408"/> 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 2<sup>32</sup>−1 and specify the size as up to 2<sup>32</sup>−1, thereby defining a partition that requires 33 rather than 32 bits for the sector address to be accessed. However, in practice, only certain [[Logical block addressing#LBA48|LBA-48]]-enabled operating systems, including Linux, FreeBSD and Windows 7<ref name="Smith_2011_gdisk"/> 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 [[Logical block addressing|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 [[USB]] [[external drive]]s, there are limitations as well. A sector size of 4096 results in an eight-fold increase in the size of a partition that can be defined using MBR, allowing partitions up to 16 TiB (2<sup>32</sup> × 4096 bytes) in size.<ref name="Superuser_2013"/> Versions of Windows more recent than Windows XP support the larger sector sizes, as well as Mac OS X, and [[Linux]] has supported larger sector sizes since 2.6.31<ref name="Seagate_4K"/> or 2.6.32,<ref name="Western-Digital_1"/> but issues with boot loaders, partitioning tools and computer BIOS implementations present certain limitations,<ref name="IBM_4K"/> since they are often hard-wired to reserve only 512 bytes for sector buffers, causing memory to become overwritten for larger sector sizes. This may cause unpredictable behaviour as well, and therefore should be avoided when compatibility and standard conformity is an issue.
Line 625 ⟶ 627:
== System bootstrapping ==
On [[IBM PC-compatible]] computers, the [[bootstrapping]] [[firmware]] (contained within the [[read-only memory|ROM]] [[BIOS]]) loads and executes the master boot record.<ref name="OSDev_2011_MBR"/> The [[PC XT|PC/XT (type 5160)]] used an [[Intel 8088]] [[Computer processor|microprocessor]]. In order to remain compatible, all x86 BIOS architecture systems start with the microprocessor in an [[X86#Operating modes|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 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 [[Volume Boot Record]] (VBR) of the targeted partition. Control is then passed to this code, which is responsible for loading the actual operating system. This process is known as [[chain loading]].
Line 638 ⟶ 640:
== Disk identity{{anchor|ID}} ==
[[File:Qtparted-usb-hdd-snapshot.png|thumb|300px|Information contained in the partition table of an external hard drive as it appears in the utility program [[QtParted]], running under Linux (with KDE)]]
In addition to the bootstrap code and a partition table, master boot records may contain a [[#DISK_ID|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).
Line 678 ⟶ 680:
* [[CS register|CS]]:[[IP register|IP]] = {{mono|0x0000}}:{{mono|0x7C00}} (fixed)
: Some Compaq BIOSes erroneously use {{mono|0x07C0}}:{{mono|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 = {{mono|0x80}}, {{mono|0x81}}, etc. However, some rare BIOSes<!-- In ca. 2002-2003. --> erroneously presented them under DL = {{mono|0x01}}, just as if they were configured as superfloppies.
: A standard conformant BIOS assigns numbers greater or equal to {{mono|0x80}} exclusively to fixed disk / removable drives, and traditionally only values {{mono|0x80}} and {{mono|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 {{mono|0x80}}. Many MBRs were coded to ignore the DL value and work with a hard-wired value (normally {{mono|0x80}}), anyway.
Line 696 ⟶ 698:
* CS:IP = {{mono|0x0000}}:{{mono|0x7C00}}{{efn|name="NB_CS-IP"}} (constant)
* DL = boot drive unit (see above)
: MS-DOS 2.
* 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.
The MBR code passes additional information to the VBR in many implementations:
* DS:SI = points to the 16-byte [[MBR partition table]] entry (in the relocated MBR) corresponding with the activated VBR. [[PC-MOS]] 5.1 depends on this to boot if no partition in the partition table is flagged as bootable. In conjunction with LOADER, [[Multiuser DOS]] and [[REAL/32]] boot sectors use this to locate the boot sector of the active partition (or another bootstrap loader like IBMBIO.LDR at a fixed position on disk) if the boot file (LOADER.SYS) could not be found. [[PTS-DOS]] 6.6<!-- TBD: not sure about 6.5x right now. --> and [[S/DOS]] 1.0 use this in conjunction with their [[Advanced Active Partition]] (AAP) feature. In addition to support for LOADER and AAPs, DR-DOS 7.07 can use this to determine the necessary INT 13h access method when using its dual CHS/LBA VBR code and it will update the boot drive / status flag field in the partition entry according to the effectively used DL value. [[Apple Darwin|Darwin]] bootloaders (Apple's <code>boot1h</code>, <code>boot1u</code>, and David Elliott's <code>boot1fat32</code>) depend on this pointer as well, but additionally they don't use DS, but assume it to be set to {{mono|0x0000}} instead.<ref name="Elliott_2009_Darwin"/> This will cause problems if this assumption is incorrect. The MBR code of OS/2<!-- TBD: Recheck! -->, MS-DOS 2.0 to 8.0, PC
* DS:[[BP register|BP]] = optionally points to the 16-byte [[MBR partition table]] entry (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.
Under DR-DOS 7.07 an extended interface may be optionally provided by the extended MBR and in conjunction with LOADER:
Line 803 ⟶ 805:
<ref name="Microsoft_2013_2581408">{{cite web |title=Windows support for hard disks that are larger than 2 TB |publisher=[[Microsoft]] |date=2013-06-26 |id=2581408 |version=1 |url=http://support.microsoft.com/kb/2581408 |access-date=2013-08-28 |url-status=live |archive-url=https://web.archive.org/web/20170427084734/https://support.microsoft.com/en-us/help/2581408/windows-support-for-hard-disks-that-are-larger-than-2-tb |archive-date=2017-04-27}}</ref>
<ref name="Superuser_2013">{{cite web |title=More than 2 TiB on a MBR disk |date=2013-03-07 |publisher=superuser.com |url=http://superuser.com/questions/562331/mbr-partition-with-more-than-2-tb |access-date=2013-10-22 |url-status=live |archive-url=https://web.archive.org/web/20170824122749/https://superuser.com/questions/562331/mbr-partition-with-more-than-2-tb |archive-date=2017-08-24}}</ref>
<!-- <ref name="FOLDOC">{{cite web |author-first=Denis |author-last=Howe |title=master boot record |website=[[FOLDOC]] |date=2009-05-19 |orig-date=1985 |url=http://foldoc.org/master+boot+record |access-date=2015-05-02 |url-status=dead |archive-url=https://web.archive.org/web/20170824002628/https://foldoc.org/master%20boot%20record |archive-date=24 August 2017 }}</ref>-->
<ref name="osdev">{{cite web |title=Partition Table |publisher=osdev.org |date=2017-03-18 |orig-date=2007-03-06 |url=http://wiki.osdev.org/Partition_Table |access-date=2017-08-24 |url-status=live |archive-url=https://web.archive.org/web/20170824123235/http://wiki.osdev.org/Partition_Table |archive-date=2017-08-24}}</ref>
<ref name="Paul_1997">{{cite web |author-first=Matthias R. |author-last=Paul |title=Caldera OpenDOS 7.01/7.02 Update Alpha 3 IBMBIO.COM - README.TXT and BOOT.TXT - A short description of how OpenDOS is booted |url=http://www.uni-bonn.de/~uzs180/download/ibmbioa3.zip |date=1997-10-02 |orig-date=1997-09-29 |access-date=2009-03-29 |url-status=dead |archive-url=https://web.archive.org/web/20031004074600/http://www-student.informatik.uni-bonn.de/~frinke/ibmbioa3.zip |archive-date=2003-10-04}} [https://web.archive.org/web/20181225154705/http://mirror.macintosharchive.org/max1zzz.co.uk/+Windows%20&%20DOS/DOS/System/Novell/Support/Bins/Op702src.zip<!-- Op702src.zip is an unofficial renamed distribution of the ibmbioa3.zip file -->]</ref>
<ref name="Paul_2017">{{cite web |title=The continuing saga of Windows 3.1 in enhanced mode on OmniBook 300 |author-first=Matthias R. |author-last=Paul |orig-date=2017-08-07 |date=2017-08-14 |work=MoHPC - the Museum of HP Calculators |url=http://hpmuseum.org/forum/thread-8774-post-77196.html#pid77196 |access-date=2018-05-01 |url-status=live |archive-url=https://web.archive.org/web/20180501185933/http://hpmuseum.org/forum/thread-8774-post-77196.html |archive-date=2018-05-01 |quote=[…] 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 record]]s 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.)</ref>
}}
Line 816 ⟶ 822:
* [http://wiki.osdev.org/MBR_(x86) Article on master boot record]
* [https://neosmart.net/wiki/mbr-boot-process/ The MBR and how it fits into the BIOS boot process]
{{Firmware and booting}}
[[Category:BIOS]]
|