Specifications
Standard Disk Format
The most widespread disk format
Introduction
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
Part |
Offset |
Size |
Description |
Code | 0000h | 446 bytes | Execution is transferred to here after the BIOS has finished. |
Partition Table | 01BEh | 16 bytes | 1st Partition Entry |
01CEh | 16 bytes | 2nd Partition Entry |
01DEh | 16 bytes | 3rd Partition Entry |
01EEh | 16 bytes | 4th Partition Entry |
Signature | 01FEh | 2 bytes | AA55h signature. 55h at offset 1FEh and AAh at offset 1FFh |
Partition Entries
Each of the partition entries from the partition table have the following structure:
Partition Entry Structure
Offset |
Size |
Description |
0000h | 1 bytes | A value of 80h means active, and 00h means inactive. |
0001h | 1 bytes | Start of partition - Head |
0002h | 2 bytes | Start of partition - Cylinder/Sector |
0004h | 1 bytes | Partition Type |
0005h | 1 bytes | End of partition - Head |
0006h | 2 bytes | End of partition - Cylinder/Sector |
0008h | 4 bytes | LBA address for the first sector in the partition. |
000Ch | 4 bytes | Number of sectors in the partition |
Packed CHS
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
15 |
14 |
13 |
12 |
11 |
10 |
9 |
8 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
Cylinder [7-0] |
Cyl. [9+8] |
Sector [5-0] |
0000h |
Partition Types
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.
MBR Code
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:
- 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.
Remember to pass the drive number along in DL.
Compatibility Advice
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.
Conclusion
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.