Disk Partition

November 9, 2009 at 2:26 pm (C programming)

Disk Partition
Partition Table contains information pertaining to disk partitions. Partition Table is the first physical sector i.e.  Head = 0, Track/Cylinder = 0, Sec = 1 or LBA = 0. Partition Table at CHS = 001 is also called MBR (Master Boot Record).

Structure of Partitioning Table
Total size of Partition Table is 512 bytes. First 446 bytes contains code which loads the boot block of active partition and is executed at Boot Time. Rest of the 66 bytes is the Data part. Last two bytes of the Data part is the Partition table signature.

OS on each Partition
On a single disk there can be 4 different file systems and hence 4 different O.S. Each O.S. will have its individual partition on disk. Data related to each partition is stored in a 16-bytes chunk within the Data Part of Partition Table.

Structure of Data Part of P.T
The following table shows the data part of partition table;
 Data_Part_of_PT

Information stored in 16 bytes chunk
PT_16bytes_chunk

PT_16bytes_chunk1

System ID byte in 16 bytes Chunk
SystemID_1

SystemID_2

Primary Partition
Partition defined in the MBR (Master Boot Record) is primary partition. Each Primary Partition contains information about its respective O.S. However if only one O.S. is to be installed then extended partitions.

Extended Partition
If a single operating system is to be kept for instance, then the disk can be divided into primary and extended partitions. Information about primary and extended partition is kept in the first physical block. The extended partition may again be divided into a number of partitions, information about further partitions will be kept in extended partition table which will be the first physical block within extended partition (i.e. it will not the first block of primary partition.). Moreover there can be extended partitions within extended partitions and such that in then end there are number of logical partitions this can go on till the last drive number in DOS.
Extended_PT_1

Extended_PT_2

Extended_PT_3

Chain of Extended Partition
 PT_Chian

Extended P.T Example:
 PT_Example
First Partition:
System ID = 0c = Windows FAT32 partition (LBA MApped)
first block = 3F
No. of blocks = 01388afc
end cylinder# = 1023
end sec # = 63 indicating a LBA disk
 
Second Partition:
System ID = 0f = Extended windows partition
Start block (relative to the start) = 01388b3b = 20482875
No. of blocks = 0390620a = 59793930

Refrence:
http://www.p-dd.com/chapter1.html