|
The Partition structure
In Dos like system, the partition table entry is stored in a data structure called Master Boot Record (MBR). MBR is the most important data structure in the disk. It lies on the first sector of the disk and is created by disk partitioning programs like fdisk. It is the most critical part of the disk. If it is damaged or erased accidentally, all the data will be lost.
The MBR structure contains of three parts: the master boot code, partition table and the signature. The master boot code is a small program which scans the partition table for the active partition, finds the starting sector of the active partition, loads the boot sector from the active partition to the memory and transfers the execution flow to the loaded code.
The last two bytes of the MBR is a magic number ‘0x55AA’ which is called the signature.
The information of the partitions lies in the Partition table entry. It starts at 446 bytes and is 64 bytes long. It contains 4 partition table entries each 16 bytes long. Thus, there can be only four primary partitions in a disk. The fields of the partition structure are given below in the form of C structure.
Struct partition {
BYTE bootIndicator;
BYTE startingHead;
unsigned startingSector :6;
unsigned startingCylinder:10;
BYTE systemId;
BYTE endingHead;
unsigned endingSector:6;
unsigned endingCylinder:10;
DWORD relativeSectors;
DWORD totalSectors;
};
bootIndicator (offset 0x01be):- The boot indicator tells if the partition is active or not. The value of 0x80 denotes active and 0x00 inactive (There must be only one active partition).
startingHead (offset 0x01bf), startingSector (offset 0x01c1), startingCylinder (offset 0x01c3):- The startingHead, startingSector and startingCylinder gives the starting position of the partition in chs mode.
systemId (offset 0x01c2):- This field gives the type of the partition. E.g. 0x83 for ext2 partition.
endingHead (offset 0x01c4), endingSector (offset 0x01c5), endingCylinder (offset 0x01c6):- These fields give the ending position of the partition.
RelativeSectors (offset 0x01c6):- Offset from the beginning of the disk in sectors.
totalSectors (offset 0x01ca):- The total sectors in the partition.
Among the four primary partitions one is the extended partition and contains the logical partitions. The Partition Table Entry in the Extended Partition points to the MBR like structure called the Extended Boot Record (EBR). There is a EBR for each logical partition. Among the four Partition table entry, first entry points to the boot sector of the logical partition. Second entry points to the EBR of the second logical partition. Thus, the logical partitions are the linked lists.
Maybe this can help , in some recovery situation.
Jose Pinto
HDDLAB
|