Standard Disk Format
The most widespread disk format
The standard described in the document is used on nearly all x86 PC's, for administration of diskspace on fixed disks. The kind of diskspace administration this standard provide is very simple. The standard allows the diskspace to be divided in up to 4 partitions (normaly refered to as primary partitions). Each of these 4 partitions can contain a separate file system. The heart of the standard is the first sector on the disk, which is reserved for the Master Boot Record (MBR).
Master Boot Record
The Master Boot Record is in first sector on the disk. This is sector 0 in LBA mode, and sector 0:0:1 in CHS
mode. This sector is checked by the BIOS for the AA55h signature at offset 1FEh, to see if drive is bootable. This signature lets the BIOS know that the code in the beginning of this sector is executable. The structure of the Master Boot Record is:
Master Boot Record Structure
|Execution is transferred to here after the BIOS has finished.
|1st Partition Entry
|2nd Partition Entry
|3rd Partition Entry
|4th Partition Entry
|AA55h signature. 55h at offset 1FEh and AAh at offset 1FFh
Each of the partition entries from the partition table have the following structure:
Partition Entry Structure
|A value of 80h means active, and 00h means inactive.
|Start of partition - Head
|Start of partition - Cylinder/Sector
|End of partition - Head
|End of partition - Cylinder/Sector
|LBA address for the first sector in the partition.
|Number of sectors in the partition
The location information for the beginning and end of the partition, consist of three bytes each. The first byte is the Head count. This is an 8 bit value, which makes room for 256 different values. The next word contains the Cylinder and Sector information and is packed together. The cylinder number is a 10 bit value and the Sector number is a 6 bit value. They are packed in the following way:
Structure of the packed cylinder/structure word
The partition type value show what kind of file system that has been installed in the partition. Partition Type = File System Identifier. The list of partition types is long, and world wide there are probably at least a few which override each other. I'm continously trying to compile a pretty complete list of file system identifiers. The most up-to-date list can be found here
The code in the MBR sector has a very limited amount of resources available. It only has a maximum of 446 bytes to get the job done. What it has to do, is locate the partition which is marked active, load the first sector from that partition into linear memory at 00007C00h, and transfer execution to that code.
This is the execution enviroment under which the MBR code must execute:
Remember to pass the drive number along in DL.
- CS:IP can be 07C0:0000 or 0000:7C00. Linear address is the same. Should be initialized.
- SS:SP is also unknown. Usually initialized.
- DL contain number of the drive from which the code was loaded from.
- The state of the other registers like AX, BX, CX, DH, SI, DI, BP, DS, ES, FS and GS are unknown.
When adding new partitions to a disk, it is adviced that the partition is aligned at sector 1. That means a partition would always start at cylinder x, head y and sector 1, where x and y can be any given number (but still within the limits of the disk).
The 8 Gb Limit
The CHS address mode has a limit of 16.515.072 sectors, which is usually 8 Gb. To add partitions beyond this limits, the drive must support the LBA address mode. With this addess mode the limit is 2 Tb. When dealing with partitions beyond this limit, the packed CHS information in the 'Start of partition' and 'End of partition' fields should be set to the maximum possible, and only the LBA address is used.
This is actually all there is to the standard disk format. But again it only devides the available space into a maximum of 4 primary partitions. The really advanced stuff comes when you want to access the data which has been saved in a file system specific way.