Hard disk partition Table detailed

Source: Internet
Author: User
Tags file system range requires

When people use a computer, sometimes because of abnormal operation, sometimes because of virus attack, can cause a partition to disappear or hard drive cannot start. The reason is that the hard disk partition table is damaged. The hard disk partition table can be said to support the hard disk normal work skeleton. It is the operating system that divides the hard disk into partitions, and then creates the file system in each partition and writes the data file. This article is mainly about the location of the partition table, structure and how each partition table is linked. When you have mastered this knowledge, Even if the partition table is damaged, you can repair the partition by manually repairing the partition table according to the remaining data.

I. Location and identification mark of the partitioned table

The partition table is typically located in the 0 Head 1 sector of a cylinder on a hard disk. The 1th partition table (also known as the primary partition table) is always located in the

(0 cylinder, 1 head, 1 sectors), the remaining partition table position can be deduced from the main partition table in turn. The partition table has 64 bytes and occupies the [441-509] byte of its sector. To determine whether the partition table, the next two bytes (also known as [510-511]) is not "55AA", if, then the partition table.

Two. Structure of partitioned Tables

The partition table consists of 4 items, each 16 bytes. Total 4x16 = 64 bytes. Each item describes the basic information for a partition. The meaning of each byte is as follows:

Partition Table Entry Meaning

Bytes Meaning
0 Activeflag. The activity mark. If 0x80h, the partition is an active partition. If 0x00h, the partition is an inactive partition.
1,2,3 The initial magnetic number of the partition, sector area code, cylinder number number one-1 bytes, sector area code-2 bytes Low 6 bits, cylinder number-2 bytes High 2 bits + 3 bytes
4 Partition file System flag:
Partition not used: 0x00h.

Extended partitions: 0x05h, 0x0fh.

FAT16 partition: 0x06h.

FAT32 Division: 0X0BH, 0X1BH, 0x0ch, 0x1ch.

NTFS partition: 0x07h.
5,6,7 The end of the partition of the magnetic number one, sector area code, cylinder number, meaning ibid.
8,9,10,11 The logical starting sector area code. Represents the number of sectors that have been used before the start of a partition.
12,13,14,15 The number of sectors that the partition occupies.

It is important to have several bytes of a partitioned table entry, which are described separately below:

1, (1,2,3) bytes

The number of magnets is represented by (1) bytes 8 bits, which range from (0 to 28-1), or 0 heads-254 heads.

The sector area code is represented by a 6-bit low (2) byte, with a range of (0--26-1) that has a range of (1 sectors-1 sectors) because the sector area code starts at 63.

The cylinder number is 2 bytes high 2 bits + (3) Byte, a total of 10 digits, the range is (0--2 10-1), namely (0 cylinder-1023 cylinder).

When the cylinder number is over 1023, the 10 digits still represent 1023, which requires attention.

(5,6,7) byte meaning ibid.

2, (8, 9, 10, 11) bytes

In the case of a primary partition table, the 4 bytes represent the difference between the starting logical sector area code of the partition and the logical 0 sector (0 cylinders, 0 heads, 1 sectors). If it is not a primary partition table, the 4 bytes either represent the difference between the starting logical sector area code of the partition and the originating logical sector area of the extended partition, or 63. Details are set out later. ---www.bianceng.cn

Attention:

1. The bytes on the sector are arranged in the order of the left low and the high right. So when you take a value, you need to reverse the byte again, so that the high byte is on the left and the low byte on the right, which requires attention when reading the logical starting sector area code and partition size. For example: The logical starting sector for the first entry is (3F 00 00 00), before converting to decimal, reverse the byte order, for (3F) and then convert to decimal, that is, 63. The same partition size (3F 7D 00) is converted to decimal (7D 3F), i.e. 8193087.

2, the logical Sector area code and (cylinder, head, sector) of the mutual conversion:

Make L = logical sector area code, C = cylinder number, H = magnetic number one, S = Sector area code.

Number of sectors per sector = 63

Number of heads per cylinder = 255

Number of slices per cylinder = number of sectors per cylinder * Number of heads per cylindrical surface

= 63x255

= 16065

The subscript of the cylindrical number starts from 0. Magnetic number One [0--254], Sector area code [1--63].

The logical sector area code subscript also starts at 0.

(Cylinder, head, sector) the formula for converting to a logical sector area code is:

L = Cx16065 + Hx63 + S-1;

For example (1 cylinder, 1 head, 1 sectors), its logical sector area code is:

L = 1x16065 + 1x63 + 1-1

= 16128

The logical sector area code is converted to (cylinder, head, sector) in the formula:

C = l/16065

H = (L% 16065)/63

S = (L% 16065)% 63 + 1

For example, the logical sector area code 16127:

C = 16127/16065 = 1

H = (16127% 16065)/63 = 0

S = (16127% 16065)% 63 + 1 = 63

i.e. (1 cylinder, 0 head, 63 sectors)

3, there are four items on the partition table, each item represents a partition, so a partition table can only represent 4 partitions. The 4 items on the primary partition table are used to represent the primary partition and the extended partition's information. Because the extended partition can have up to one, the hard disk can have up to four primary partitions or three primary partitions, one extended partition. The remaining partitioned tables represent logical partitions.

It is necessary to elaborate here that the logical areas are all in the extended partition, and the number of logical partitions is unlimited.

4, the partition table is usually in the sector (0 head, 1 sectors), and the partition's starting sector is usually located (1 head, 1 sectors), the middle of 63 hidden sectors.

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.