China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-20 10:37
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » Repost: Introduction to Hard Disk Partition Structure by RobertYore DigestII View 17,763 Replies 1
Original Poster Posted 2002-10-26 00:00 ·  中国 江西 吉安 电信
高级用户
★★
Credits 667
Posts 135
Joined 2002-10-25 00:00
23-year member
UID 62
Gender Male
Status Offline
Main structure explanation of hard disk partitions: (Cylinder/track-Side/head-Sector address abbreviated below as ?-?-?) 《Primary partition》 Name Address Length (sectors)
-----------------------------------------------------------
Main Boot Record: 0-0-1 1 System Secotrs: 0-0-2,0-0-63 62 Boot sector (Boot): 0-1-1 1 In a FAT16 system, this sector contains the BPB (BIOS Parameter Block) table, which describes the logical disk structure, including the number of hidden sectors (calculated starting from 0-1-1), the number of FAT sectors, the number of FAT copies, the total number of hard disk heads, the maximum number of root directory entries, etc. In a FAT32 system, the offset of the BPB table is different from FAT16, but the entries are basically the same. The entire hidden sector part is used as the description area for the logical disk. Hidden Secotrs: FAT16 0-1-1 1 FAT32 0-1-1 32 File Allocation Table: FAT16 0-1-2 Varies according to logical disk capacity FAT32 0-1-33 Varies according to logical disk capacity Explanation: Each FAT16 entry consists of 2 bytes (16 bits); usually the cluster pointed to by each entry contains 64 sectors, i.e. 32K bytes. The maximum logical disk capacity is 2047MB. Each FAT32 entry consists of 4 bytes (32 bits); usually the cluster pointed to by each entry contains 8 sectors, i.e. 4K bytes. The minimum logical disk capacity is 2048MB. For the C partition, at offset 01c2H of the MBR, FAT16 is 06H, FAT32 is 0CH. *** The relevant formulas are: Length of each sector=512 bytes Total number of clusters=logical disk capacity/cluster capacity Total number of clusters=FAT table length (bytes)/length of each entry (bytes)-2 FAT table length=logical disk capacity/cluster capacity*length of each entry The beginning of the FAT table consists of the media descriptor + a string of “occupied” flags: FAT16 hard disk----F8 FF FF 7F FAT32 hard disk----F8 FF FF 0F FF FF FF 0F Each valid FAT structure area contains two completely identical copies: FAT1, FAT2 File Directory Table, i.e. the root directory area, also called the ROOT area: It immediately follows the next sector after FAT2, and is 32 sectors long (256 entries). If long filenames are supported, then each entry is 64 bytes, of which the first 32 bytes are the long filename link description; the last 32 bytes are the file attribute description, including file length, starting address, date, time, etc. If long filenames are not supported, then each entry is a 32-byte attribute description. Data Area: It immediately follows the next sector after the FDT, and continues until the ending address of the logical disk. 《Extended partition》 Name Address Length (sectors)
-----------------------------------------------------------
Extended partition (Extend Partition): ?-y-1 1 System Secotrs: ?-y-2,?-y-63 62 Boot sector (Boot): ?-(y+1)-1 1 The following items are the same as the primary partition…… Explanation of finding extended logical disks: 1 In the partition table of the primary partition, find the physical address (track-head-sector) of the extended partition 2 At the end of the sector pointed to by the extended partition address, look up the extended partition table (extended volume); its structure is the same as the primary partition table 3 In the physical address in the extended partition table, add 1 to the number of heads and leave the rest unchanged; this is the physical address of the BOOT sector of the first logical drive (such as drive D) 4 According to the system classification of the extended drive (FAT16/FAT32, with 2048MB as the boundary), check the FAT table and ROOT area 5 If there are also drives E, F…… etc., then continue looking for BOOT sectors that meet the requirements; the BOOT sector is specified to be sector 1 of each head Appendix: Explanation of partition table entry structure The partition table starts from offset 01BEH of the MBR sector. There are 4 partitions in total, each partition being 16 bytes; The structure of the first partition is as follows: Offset Value Description 01BE 80 ; boot flag 01BF 01 ; head number where the partition begins 01C0 01 ; sector number where the partition begins, low 6 bits; cylinder number, high 2 bits 01C1 00 ; cylinder number where the partition begins, low 8 bits 01C2 ?? ; partition type, 06=FAT16 C, 0C=FAT32 C, 05=extended partition 01C3 ?? ; head number where the partition ends 01C4 ?? ; sector number where the partition ends, low 6 bits; cylinder number, high 2 bits 01C5 ?? ; cylinder number where the partition ends, low 8 bits 01C6-01C9 ?? ; related sector count, usually 63 01CA-01CD ?? ; total number of sectors in the partition Partition table ending flag: 01FE 55 01FF AA Explanation of two obvious BUGs in versions above MS-DOS 6.xx: 1 FDISK.EXE When FDISK creates partitions, it overwrites sectors 1 and 7 of each head, filling them with 512 bytes of F6; the covered area starts from the BOOT area, and the ending address is unclear. 2 Boot process During the MS-DOS boot process (including MS-DOS 7.XX booted by WINDOWS 9X), it will search every logical drive. If the partition type flag of some logical disk in the extended partition table is changed to 05H by a virus or other factors (such as a certain version of Wang Jiangmin's KV??? which, in order to “punish” piracy……), and that partition pointer is then made to point to the main boot record at the head of the hard disk, then…… hehe, take another look and see whether your hard disk can still boot? Can it still boot with a floppy disk (MS-DOS 5.0 or above)? ……Either change a byte, or use DOS 3.31 (can you still find it?) to boot…… Note: the physical address information in the above partition table is relatively old. If any friend has new materials on LBA hard disk BIOS, please don't hesitate to enlighten me.
================================= kickout
大功告成,打个Kiss!
Floor 2 Posted 2004-06-23 00:00 ·  中国 天津 电信
中级用户
Credits 297
Posts 44
Joined 2004-06-15 00:00
22-year member
UID 26749
Gender Male
Status Offline
Forum Jump: