Final Year Project:
Using Linux Filesystems Under Windows
Chris Bryden
BEng. Electronics and Software Engineering
School of Computer Science
University of Birmingham
4
2.2 Hard Disk Partitions and Logical Sectors
Hard disks are often divided up into different sections called partitions.
Each logical partition can behave like a hard drive in itself. For example, in MS-
DOS, a disk can be divided into two partitions, the primary and extended
partitions. Logical drives can then be defined in the extended partition, each of
which has its own drive letter and behaves like a separate disk.
A hard disk can be divided into a maximum of four partitions. The
information about these partitions is held in a special part of the disk called the
partition table. It is located at Cylinder 0, Head 0, Sector 1 on the disk. The
structure of a partition table entry is shown below:
Each partition on a disk has an entry of the form shown above in the partition
table, the function of each of the values is as follows:
·
=boot_ind -
This indicates whether the partition can be booted from. A value
of 0x80 indicates that the partition is bootable.
·
=head, sector and cyl - These make up the CHS location of the start of the
partition.
·
=sys_ind - This is a hex value that represents the type of partition to which the
entry refers, a few relevant types are:
0x05 - DOS extended partition.
0x06 - DOS primary partition.
0x82 - Linux swapfile partition
0x83 - Linux filesystem partition.
·
=end_head, end_sector and end_cyl - These make up the CHS location of the
end of the partition.
·
=start_sectlo and start_secthi - The low and high byte of the start sector,
with sectors numbered form zero upwards.
·
=nr_sectslo and nr_sectshi - The low and high byte of the total number of
sectors that make up the partition.
struct partition {
unsigned char boot_ind;
unsigned char head;
unsigned char sector;
unsigned char cyl;
unsigned char sys_ind;
unsigned char end_head;
unsigned char end_sector;
unsigned char end_cyl;
unsigned short start_sectlo;
unsigned short start_secthi;
unsigned short nr_sectslo;
unsigned short nr_sectshi;
};