V. Hard Drive boot area and Partition Table

Source: Internet
Author: User

V. Hard Drive boot area and Partition Table

Papayas

20080901

I. Preface

The hard disk boot reading process is similar to that of a CD and a floppy disk. A boot sector is required.
The MBR (Master Boot Record) is also called the Master Boot Record. The boot area is the most important data structure on the hard disk. When
When you use the partition software to create a partition, the MBR is automatically created. This article describes the logic structure of the boot server.

<More related content: http://blog.csdn.net/liwei_cmg/archive/2008/03/06/2154833.aspx>
 
Ii. Boot Sector

On a Wintel machine the BIOS selects a boot device, then it copies the first sector from
Device (which may be an MBR, VBR or any executable code), to address location 0x7c00.
0x7c00 has been described in the article "discussing computer storage IV. boot from a floppy disk to your own operating system.
 
The Boot Sector (Main Boot Sector) is a sector that exists in a floppy disk, hard disk, or similar storage device. It mainly stores the boot System
Is the first sector of the boot media.
There are two types of Boot Sector: MBR (Master Boot Record) and VBR (volume Boot Record ).

A Master Boot Record (MBR) is the first sector of a data storage device that has been
Partitioned. The MBR sector may contain code to locate the active partition and invoke its
Volume Boot Record.
A volume Boot Record is the first sector of a data storage device that has not been partitiOned,
Or the first sector of an individual partition on a data storage device that has been partitioned.
It may contain code to load and invoke an operating system (or other standalone Program)
Installed on that device or within that partition.

The partition information contained in the MBR. After reading the information, the system forwards it to the VBR of the corresponding primary partition (set as active) to guide
The operating system code in the corresponding partition.
The last two bytes of the boot sector must be 0xaa55, which is called the Boot Sector signature ).

Iii. MBR (Master Boot Record)

MBR Structure
 
Address Description Size
0000 code area 440 (max 446)
01b8 optional disk signature 4
01bc usually nulls; 0x0000 2
01be table of primary partitions
(Four 16-byte entries, IBM
Partition Table Scheme) 64
01fe 55 h MBR signature;
01ff aah 0xaa55 [1] 2
 
MBR, total size: 446 + 64 + 2 = 512

MBR is a 512-byte Boot Sector ("LBA 0") that contains program code and a Small Partition Table. MBR not on Hard Disk
The Boot Sector located before the first partition.
 
<Bootloader>
The first 446 bytes (0x0000 to 0x01bd) of MBR. The primary Boot Loader contains executable code and error messages.
Text.

<Partition Table>
The next 64 bytes (0x01be to 0x01fd) of MBR record the basic partition information of the disk. The primary Partition Table is divided
Each item contains 16 bytes of information about each primary partition. Therefore, up to four primary partitions can be created ).

Partition Table Structure

Offset description
0x00 (1 byte) status [7] (0x80 = bootable, 0x00 = non-bootable, other = malformed [8])
0x01 (3 bytes) cylinder-head-sector address of the first sector in the partition [9]
0x04 (1 byte) partition type [10]
0x05 (3 bytes) cylinder-head-sector address of the last sector in the partition [11]
0x08 (4 bytes) logical block address of the first sector in the Partition
0x0c (4 bytes) Length of the partition, in sectors

Byte state: the partition status 0x00 is not activated, and 0x80 is activated.
Byte starthead: Start head number of the partition
Word startsc: Start slice and Cylinder Number of the partition. The low-byte 6-bit is the sector number.
The 2-digit height is the 9th and 10th digits of the cylinder number, and the 8-digit height is the 8-digit lower part of the cylinder number.
Byte type: partition type, such as 0x00 = empty, 0x0b = FAT32, 0x07 = NTFS, 0x82 = Linux swap, 0x83 Linux native partition...
Byte endhead: the end head of the partition.
Word endsc: End sector and Cylinder Number of the partition, which are defined in the same way as before.
DWORD relative: Address of the partition relative sector in linear addressing mode
DWORD sectors: partition size (total number of sectors)

External link: 0x04 (1 byte) partition type [10] http://www.win.tue.nl /~ AEB, partitions, partition_types-1.html

Iv. VBR (volume Boot Record)

After the system is powered on and started, the BIOS is guided and the code in MBR is executed.
In mode, the Execution Code in MBR is the real mode machine command. When MBR is executed, it will look for the active partition (
State of the primary partition record), and then load the VBR of the active partition.

Real mode:
To this day, even the newest x86 CPUs start in real mode at power-on, and can run software
Written for any previous chip.
Almost all modern x86 operating systems (FreeBSD, Linux, OS/2, Solaris, Windows 95 and
Later, etc.) switch the CPU into protected mode at startup.

VBR generally contains the command to start the operating system. The device is located in the first sector of the device
The partition is located in the first sector of the partition.

5. Extended partitions and ebr (Extended Boot Record)

Since the (MBR) Primary Partition Table can only store four partitions, it cannot meet the actual needs. Therefore, an extended partition is designed.
Format. The basic information of an extended partition is stored in the MBR Partition Table. An extended partition can be divided into multiple subpartitions. Sub-Score
The partition information is stored in the form of a linked list. Subpartitions are hard disk partitions that we often see, such as D: e.
The primary partition table has a basic extended partition item. All the extended sub-partitions belong to it. That is to say, all other extensions
The partition space must be included in this basic extended partition. For DoS/Windows, extended partitions are of the following types:
0x05 0x0f, while Linux is 0x85.
Extended subpartitions are stored in a linked list. The data items of the last extended subpartition are recorded in the previous extended subpartition
In a partitioned table, the space of two extended subpartitions does not overlap.
An extended partition can be viewed as a complete hard disk and can be used only after further partitioning.
 
EBR contains information about extended sub-partitions, which can contain multiple EBR and correspond to multiple extended sub-partitions (
As a logical drive ). The first EBR is the first subpartition, which is naturally located in the first sector of the extended partition.
 
Common Structure of extended boot records:
 
Offsets (within EBR sectors) contents size in bytes
000-1bd generally unused; normally filled with zero-bytes 446
18A-192 possible IBM Boot manager menu entry
1be-1cd Partition Table's first entry 16
1ce-1dd Partition Table's second entry 16
1de-1fd unused, but shoshould be filled with zero-bytes 32
1fe Boot Record Signature: 0xaa55 (aa55h) 2
1ff
EBR, total size: 446 + 16 + 16 + 32 + 2 = 512

The first partition table's first entry records the basic information of this extended subpartition.
The second item (partition table's second entry) in the Partition Table records information about the next subpartition of the extended subpartition.

The partition table's entry data structure is consistent with the MBR mentioned above.
 

Reference: Wikipedia

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.