Master Boot Record MBR, Boot Record mbr

Source: Internet
Author: User

Master Boot Record MBR, Boot Record mbr

Master Boot Record(Master Boot Record, abbreviated as MBR), also calledPrimary Boot SectorIt is the first sector that the computer must read when accessing the hard disk after it is started. Its three-dimensional address on the hard disk is (cylindrical, Head, Sector) = (, 1 ). When in-depth discussion of the internal structure of the primary Boot Sector, the first 446 bytes of content is sometimes referred to as the "primary Boot Record" (MBR ), it is followed by a 4-Byte "disk partition table" (DPT) and a 2-byte ending sign (55AA ). Therefore, when using the term "primary Boot Record" (MBR), you need to determine whether it refers to the entire primary boot sector or the first 446 bytes of the primary Boot Sector.

Standard MBR Structure
Address Description Length
(Bytes)
Hex Oct Dec
0000 0000 0 Code Area 440
(446 at maximum)
01B8 0670 440 Select disk flag 4
01BC 0674 444 It is generally null, and 0x0000 2
01BE 0676 446 Standard MBR Partition Table Planning
(Four 16-byte primary partition table entries)
64
01FE 0776 510 55 h Valid MBR identifier:
0x55AA
2
01FF 0777 511 AAh
MBR, total size: 446 + 64 + 2 = 512

The primary Boot Sector records the information about the hard disk and the size and location of each partition of the hard disk, which is an important entry to data information. If it is damaged, the basic data structure information on the hard disk will be lost. The original data can be accessed only after the data structure information is reconstructed in a tedious way. Information in the primary boot sector can be written to the software through any partition tool based on an operating system, but it has no specific relationship with an operating system, that is, if a valid Master Boot Record is created, any operating system can be guided (the operating system is created on an advanced formatted hard disk partition and is associated with a certain file system ).

For a hard disk, the possible number of bytes in a sector is 128 x 2n (n = ). In most cases, take n = 2, that is, the size of a single sector (sector) is 512 bytes.

 

Composition of the Master Boot Record
Startup code

The primary Boot Record starts with the first-stage boot code. The main function of the hard disk boot program is to check whether the partition table is correct and give control to the boot program (such as gnu grub) on the hard disk after the system hardware completes the self-check ). It does not rely on any operating system, and the startup code can be changed to implement multi-system boot.

Hard Disk Partition Table
Hard Disk Partition structure information
Offset Length (bytes) Meaning
00 H 1 Partition status: 00 --> inactive partition; 80 --> active partition;
Other values are meaningless.
01 H 1 The start head of the partition. All 8 bits are used.
02 H 2 The sector id (SECTOR) at the beginning of the partition, which occupies the bits of 0-5 in hours;
The starting magnetic column number (CYLINDER) of the partition, occupying
The 2h bits are 6-7 and 03H all 8 bits
04 H 1 File System flag
05 H 1 Partition end HEAD (HEAD), all 8 bits are used
06 H 2 Partition end fan area number (SECTOR), occupying the digit of 06H 0-5;
The ending column number (CYLINDER) of the partition, occupying
All 8 bits of 6-7 and 07H of 06H
08 H 4 Partition start line
0CH 4 Total number of partitions

The Hard Disk Partition Table occupies 64 bytes of the primary Boot Sector (offset 01BEH -- offset 01FDH). You can describe the information of the four partitions. The information of each partition occupies 16 bytes. For the definition of each byte, seeHard Disk Partition structure information. The following is an example:

If the information of a partition in the hard disk partition table is as follows:

80 01 01 00 0B fe bf fc 3F 00 00 00 7E 86 BB 00

We can see that the "80" at the beginning is a partition activation sign, indicating that the system is bootable; "01 01 00" indicates that the start of the partition is 1, the START slice number is 1, and the START cylinder number is 0. "0B" indicates that the partition system type is FAT32. Other commonly used slice numbers include 04 (FAT16) and 07 (NTFS ); "fe bf fc" indicates that the head number of the partition end is 254, the end sector number is 63, and the end cylindrical number is 764; "3F 00 00" indicates that the relative sector number of the first sector is 63; "7E 86 BB 00" indicates that the total number of sectors is 12289662.

For hard disks larger than GB in the modern era, the CHS cannot be expressed. The BIOS uses the LBA mode. for excess hard disks, the CHS value is always FEFFFF and ignored, directly use the 4-byte relative value of 08-0f before internal conversion.

Ending flag

Ending flagThe last two bytes of 55, AA (offset 1FEH-offset 1FFH) indicate whether the primary Boot Record is valid.

Read process of the primary Boot Sector
  • Start or restart the system.
  • In fact, the BIOS not only checks whether 0000: 7CFEH-0000: 7 CFFH (MBR end flag) is equal to 55AAH, check whether the disk has write protection or whether active partitions exist in the primary Boot Sector. If the disk has write protection, the disk write protection error message is displayed. If no active partition exists in the disk, the following information is displayed: "Remove disk or other media Press any key to restart ".
Master Boot Record and hard disk partition

SlaveMaster Boot RecordIt can be known that it only contains a 64-byteHard Disk Partition Table. Because each partition information requires 16 bytes, a hard disk using an MBR partition structure can only recognize up to four Primary partitions (Primary partition ). Therefore, it is impossible for a hard disk to have more than four primary partitions. Here we need to introduce the extended partition. Extended partitions are also the primary partitions, but they differ from the primary partition in that they can be divided into countless logical partitions theoretically.

The boot records of the logical drive in the extended partition are chained. Each logical partition has a structure similar to that of MBR.Extended boot records(EBR), the first item of its partition table points to the guiding sector of the logical partition itself, the second item points to the EBR of the next logical drive, the third and fourth items of the partition table are not used.

In Windows, by default, only one primary partition is allocated to the system, and all the remaining parts are allocated to the extended partition. Note the following points:

  • In an MBR partition table, a maximum of four primary partitions or three primary partitions + one extended partition can be created. That is to say, only one extended partition can be created, and then multiple logical partitions can be subdivided.
  • In Linux, hard disk partitions are named sda1-sda4 or hda1-hda4 (where a indicates that the hard disk number may be a, B, c, and so on ). In an MBR hard disk, the Partition Number 1-4 is the primary partition (or extended partition), and the logical Partition Number can only start from 5.
  • In an MBR partition table, the maximum capacity of a partition is 2 TB, and the START cylindrical of each partition must be within the first 2 TB of the disk. You have a 3 t hard disk. You should divide it into at least two partitions as required, and the starting sector of the last partition should be located in the first 2 t Space of the hard disk. If the hard disk is too large, you must use GPT instead.
Relationship between MBR Partition Table and GPT Partition Table

With a maximum of 2 TB (Terabytes) supported and each disk can have up to 4 primary partitions (or 3 primary partitions, 1 extended partition, and unlimited logical drives)MBRCompared to the disk partition style, the GPT disk partition style supports a maximum volume of 128 EB (Exabytes) and there is no upper limit on the number of partitions per disk, only limited by the operating system (because the Partition Table itself requires a certain amount of space, when planning hard disk partitions, the space left for the Partition Table determines the maximum number of partitions, IA-64 Windows limits a maximum of 128 partitions, which is also the Partition Table specified by the EFI StandardMinimumSize ). Unlike an MBR partitioned disk, the crucial platform operation data is located in the partition, not in a non-partition or hidden sector. In addition, GPT partition disks have backup partition tables to improve the integrity of the partition data structure.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.