Industrial Training


The murky depths of Partition Table (PT) don't look terribly inviting to most people. It is viewed as sinister and full of technical details that most people do not want to test their strengths with. But if we examine the PT with a thick lens it is straight and simple. Moreover since you have been using hard disks since you were this high in Computers, it's all the more meaningful to get to know the details of the PT if it is the driving force behind the hard disk.

PT exists only on hard disk. This is because today we have hard disks which range in capacity from 20 mb to 300 mb. So huge is this capacity that it would be foolish to use the entire hard disk only for DOS. Hence it is divided into several logical parts called partitions. One partition may contain DOS whereas the other might contain Xenix an so on. The hard disk is partitioned using DOS's FDISK command. While partitioning the hard disk FDISK stores the details about where one partition ends and the next begins, which is the bootable partition etc. in the first physical sector ( side 0, track 0, sector 1 ). It also stores a program called Master Boot Program in the PT. Thus a PT consists of data part and the code part. The following figure 1 shows how the PT is logically divided.


The data part begins at 447th byte. The last two bytes in the PT are always 0x55, 0xAA. The data part is 64 bytes long and is further divided into four parts of 16 bytes each. Each 16 bytes chunk consists of information about a partition on the hard disk. Hence there can be maximum four partitions on the hard disk. The break-up of 16 bytes is given below.

Byte Meaning
0 Boot indicator. Contains 0x80 for the active partition, 0 for all others. Only one partition can be active at a time.
1 Side where the partition begins.
2 The low six bits are the sector where the partition begins. The high two bits are the two high bits of the track where the partition begins.
3 Low order eight bits of the track where the partition begins.
4 Partition type indicator. The contents os this byte indicates the type of the partition. Following values may exist.
0 - Unused partition
1 - DOS partition that uses a 16-bit FAT
2 - Xenix partition
4 - DOS partition that uses a 16-bit FAT
5 - Extended Partition
6 - Huge Partition
5 Side where the partition ends.
6 Low order six bits are the sector where the partition ends. The high two bits are the high two bits of the ending track number.
7 Low eight bits of the track number where the partition ends.
8-1 Double word containing the number of sectors preceeding the partition. Low order word is stored first.
12-15 Double word containing the number of sectors in the partition. Low order word is stored first.

let us put the theorey into a program which analyses the PT. Here it is.

 # include "bios.h" 


struct partition 


unsigned char bootable ;   unsigned char start_side ; 

unsigned int start_sec_cyl ;   unsigned char parttype ; 

unsigned char end_side ;   unsigned int end_sec_cyl ; 

unsigned long part_beg ;   unsigned long plen ; 

} ; 

    struct part 


unsigned char master_boot[446] ; 

struct partition pt[4] ; 

int lasttwo ; 

} ; 

struct part p ; 


main(  ) 


unsigned int s_sec, s_trk, e_sec, e_trk, i, t1, t2 ; 

char type[20], boot[5] ; 


biosdisk ( 2, 0x80, 0, 0, 1, 1, &p ) ; 


printf("\nPart.   Boot   Starting locationEnding      Location    Relative  Number of"); 

printf("\nType   Side Cylinder  Sector  Side    Cylinder Sector  Sectors   Sectors\n"); 


for ( i = 0 ; i <= 3 ; i++ ) 


if ([i].bootable == 0x80 ) 

strcpy ( boot, "Yes" ) ; 


strcpy ( boot, "No" ) ; 


switch ([i].parttype ) 


case 0 : 

strcpy ( type, "Unused" ) ; break ; 

case 1 : 

strcpy ( type, "12-Bit" ) ; break ; 

case 2 : 

strcpy ( type, "Xenix" ) ; break ; 

case 4 : 

strcpy ( type, "16-Bit" ) ; break ; 

case 5 : 

strcpy ( type, "Extended" ) ; break ; 

Hi I am Alfred.