Hard Disk The first sector of is retained as the Main Boot Sector, which is located in the 0 track 0 cylinder 1 Sector of the entire hard disk, including the Hard Disk Master Boot Record MBR (Main Boot Record) and Partition Table DPT (Disk Partition Table ). The primary Boot Record is used to check whether the partition table is correct and which partition is the boot partition. Program At the end, the Startup Program (that is, the operating system boot sector) of the partition is transferred to the memory for execution. As for the partition table, many people know that the start mark is 80 h or H, and the end mark is 55aah, Which is 64 bytes in total and is located at the end of the local slice.
Hard drive primary Boot Sector= Hard Disk Master Boot Record (MBR) + Hard Disk Partition Table (DPT)
Fdisk is used for hard disk partitioning. It belongs to the entire hard disk instead of an independent DOS partition. It is a necessary condition for proper boot and use of the hard disk.
Physical location: 0 cylindrical 0 head 1 Sector (cylinder 0, head 0, Sector 1)
System secotrs: 0c-0h-2s, 0c-0h-63s, 62 sectors in total
Size: 512 bytes
Among them: MBR 446 bytes (BD), DPT 64 bytes (01be--01fd), ending mark 2 bytes (55 aa)
Function: MBR directs the system to DBR by checking the DPT partition information.
Details: (debug-A: mov ax, 0201 mov BX, 0200 mov CX, 0001 mov dx, 0080 INT 13)
000h--08ah MBR Startup Program (search for boot partition)
08bh--0d9h MBR startup string
0dah--1bch ("0 ")
1beh--1fdh Hard Disk Partition Table
1feh--1ffh end sign (55aa)
Hard Disk Partition Table (DPT)
Offset address01be
Number of bytes 1
Meaning analysis partition type: 00 indicates inactive partitions; 80 indicates active partitions; others are invalid partitions.
Offset address01bf ~ 01c1
3 bytes
Start address of the definition analysis partition (Head/sector/cylindrical): Generally, the start address of the first partition starts from 1 Head, 0 cylinder, and 1 sector. Therefore, the three bytes should be 010100.
Offset address01c2
Number of bytes 1
Meaning Analysis Common partition operating system types: 00 [none-use] 04 [dos fat16 <32 m] 05 [extend] 06 [dos fat16> 32 m] 07 [NTFS (OS/2)] 0b [FAT32] 83 [Linux> 64 m]
Offset address01c3 ~ 01c5
3 bytes
Definition Analysis end address of the partition (Head/sector/cylindrical)
Offset address01c6 ~ 01c9
4 bytes
Description analysis: Start logical sector of the partition [Address of the partition relative sector in linear addressing mode]
Offset address01ca ~ 01cd
4 bytes
Meaning analysis the total number of slice occupied by the partition
Note:Note that the shard start address (Head/sector/cylindrical) and end address (Head/sector/cylindrical) are allocated in bytes:
00000000 01000001 00010101 (the first byte is the head, and the second byte is 2 ~ 7-bit slice, the second byte 0 ~ The first and third bytes are Cylindrical columns)
DPT has a total of 64 bytes (01be--01fd). As shown above, each partition occupies 16 bytes, so it can represent four partitions, this is why the sum of the primary and extended partitions of a disk can only be four.
Logical drive
The extended partition information is located in the hard disk partition table (DPT) shown above, while the logic drive information is located in the Start sector of the extended partition, that is, the slice corresponding to the start address (cylindrical/sector/track) of the partition. The difference between the information in this slice and the primary boot slice of the hard disk does not include MBR, the 16-byte partition information indicates the start and end addresses of the logical drive.
Therefore, when the disk contains only one primary partition and one extended partition (including multiple logical drives, even if data in the primary Boot Sector of the hard disk is lost (including DPT) due to viruses or other causes, the entire hard disk can be recovered through the data on the logical drive.
Absolute sector = head Number * number of sectors per [3f] + Cylinder Number * Maximum number of cores [generally ff] * number of sectors per sector + sector number-1
Maximum number of magnetic heads = (total number of sectors + start logical fan-end of slice)/number of each slice [3f])-head no.)/cylinder No.
Or the maximum number of magnetic heads = (starting from the logical fan + 1-starting from the slice)/number of each slice [3f])/starting from the head number
For example, the following is a hard disk partition.
Head cylindrical sector head cylindrical sector start fan (logic) end fan total sectors
MBR 0 1 0
C 1 0 1 239 276 63 4,188,239 4,188,177
Expansion 0 277 1 239 554 63 4,188,240 8,391,599 4,203,360
D 1 277 1 239 554 63 4,188,303 8,391,599 4,203,297
If the primary Partition Table is corrupted, You can manually search for the logical drive data contained in the extended partition table. In this example, the data corresponding to the D disk is used, and then the start fan (logical) is used) 63 is the start fan (logic) of the corresponding extended partition. Changing the start address (Head/sector/cylinder) to 0 is the start address of the extended partition. then, you can use the extended partition to obtain the information of primary partition C, and then you can use the fdisk/MBR command and manually enter the partition table to restore the entire hard disk.
Partition Table data corresponding to this example:
80 01
01 00 06 EF 7f 14 3f 00 00 00 11 E8 3f 00 00 00
41 15 05 ef bf 2a 50 E8 3f 00 60 23 40 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA
AlgorithmProcess: (take the first partition as an example)
EF 7f 14 corresponds to the head number EFH = 239d, the cylinder number 7f high 2 and 14 h = 114 H = 276d, the fan area number 7f low 6 bits = 3fh = 63d
Start logic fan = 3f 00 00 = 3fh = 63d
Total number of partitions = 11 E8 3f 00 = 3fe811h = 4188177d
Maximum number of magnetic heads = (4188177 + 63)-63)/63)-239)/276 = 240d = 0f0h
01 01 00 logical fan = 1*63 + 240*0*63 + 1-1 = 63d
Logical fan of EF 7f 14 = 239*63 + 240*276*63 + 63-1 = 4188239d
Extended partition table data:
00 01
41 15 07 ef bf 2a 8f E8 3f 00 21 23 40 00
Note: The start sector of the logic and the total number of partitions are low on the left. For example, if the start address of the extended partition in this example is 8f E8 3f 00, it must be changed to 00 3f E8 8f before decimal conversion, the total number of partitions occupied by 21 23 40 00 must be changed to 00 40 23 21 first. Similarly, when you manually enter this value, you must also perform high/low conversion.
Description of extended Logical Disk search:
1. In the Partition Table of the primary partition, find the physical address of the extended partition.
2. Find the extended partition table (expansion volume) at the end of the sector indicated by the extended partition address. The structure is the same as that of the primary partition table.
3. Expand the physical address of the partition table. Add 1 to the number of Magnetic Heads. If the remaining values remain unchanged, the physical address of the Boot Sector of the first logical drive (such as disk D) is used.
4. view the fat table and the root partition according to the system category of the extended drive (fat16/FAT32, with a limit of 2048mb ).
5. If there is e, f ...... Wait for the disk, then continue to find the required Boot Sector, the boot sector is specified in the first sector of each head
The system startup process consists of the following steps (taking the hard disk as an example)
1. boot
2. the BIOS power on self test -- Post memory address is 0 FFFF: 0000
3. Read the first sector of the hard disk (0-headed 0-way [cylindrical] 1-sector, that is, Boot Sector) into the memory address 0000: 7c00.
4. Check if (Word) 0000: 7dfe is equal to 0xaa55. If not, try other startup media again.
If no other boot media exists, the system displays "no rom basic" and then crashes.
5. Jump to 0000: 7c00 and execute the program in MBR.
6. MBR first copies itself to 0000: 0600, and then continues to execute.
7. Search for active partitions in the primary partition table. If no active partition is found or more than one active partition exists, stop again.
8. Read the first sector of the active partition into the memory address 0000: 7c00.
9. Check (Word) 0000: 7dfe whether it is equal to 0xaa55. If it is not equal, "missing Operating System" is displayed and then stop, or try to start a floppy disk.
10. Jump to 0000: 7c00 and continue executing the Startup Program for the specific system.
11. Start the system...
In the above steps, steps 2, 3, and 4 are completed by the BIOS boot program. 6, 7, 8, 9, and 10 are completed by the MBR boot program.