Partition Table: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
(Removed PFR tag)
No edit summary
Line 1: Line 1:
The following information about Partition Tables only applies to hard disk drives. Most other storage devices use other partitioning techniques, if they even use partitioning at all.
The information about primary partitions and an extended partition is contained in the Partition Table, a 64-byte data structure located in the first sector (cylinder 0, head 0, sector 1) of the hard drive. The Partition Table conforms to a standard layout that is independent of the operating system. Each Partition Table entry is 16 bytes long, making a maximum of four entries available. Each entry starts at a predetermined offset from the beginning of the sector, as follows:

==MBR==
The Master Boot Record is the traditional way of storing partition information about a drive, along with some boot code. Almost all PCs still use an MBR for this purpose. You can find more information about the MBR boot process in [[MBR (x86)]]. MBRs are nearly obsolete at this time, because of the 32 bit design of the LBA fields in the Partition Table. One possible replacement for the MBR system is GPT (see below).

Information about primary partitions and an extended partition is contained in the Partition Table, a 64-byte data structure located in the first sector (cylinder 0, head 0, sector 1 -- or, alternately, LBA 0) of the hard drive. The Partition Table conforms to a standard layout that is independent of the operating system. Each Partition Table entry is 16 bytes long, making a maximum of four entries available. Each entry starts at a predetermined offset from the beginning of the sector, as follows:


{| {{wikitable}}
{| {{wikitable}}
Line 18: Line 23:
|0x01EE (494)
|0x01EE (494)
|}
|}



Each entry has the following structure:
Each entry has the following structure:
Line 29: Line 33:
| 0
| 0
| byte
| byte
| Boot indicator, 00 = no, 80 = bootable
| Boot indicator bit flags, 0 = no, 0x80 = bootable
|-
|-
| 1
| 1
Line 62: Line 66:
| dword
| dword
| Relative Sector (to start of partition)
| Relative Sector (to start of partition)
| (This field can be considered the partition's starting LBA value)
|-
|-
| 12
| 12
Line 67: Line 72:
| Total Sectors in partition
| Total Sectors in partition
|}
|}

Please note: the Partition Table entries are <b>not</b> aligned on 4 byte boundaries, neither are the two dword LBA entry values -- so the LBA values cannot be copied directly into a register, if the MBR is itself loaded into memory on a 4 byte boundary.
The Cylinder, Head, Sector fields (taken together) are only 3 bytes (28 bits) long. The ending CHS value of the partition must be stored in one of those 3 byte fields, and Sector values of 0 are illegal. This means that the CHS fields "max out" on a drive that is approximately 8GB in size -- and are therefore useless on almost all current drives. For a drive bigger than 8GB, generally the CHS fields are set to Cylinder = 1023, Head = 255, Sector = 63 -- which is considered an invalid setting.
Since the two CHS fields are unused in all current large drives, the definition of an MBR could theoretically be modified to set a flag in the "bitflags" field, eliminate the two CHS fields, and then extend the "starting LBA" and partition sector count fields to be 48 bits long. This would allow MBR-type partition tables to be used with drives larger than 8TB.

== GPT ==

GPT is an updated Partition Table standard, that has been adopted as the recommended partition mechanism under UEFI. It does not contain the artificial 28 bit or 32 bit limitations of the MBR Partition Tables. It also contains enhancements to the concept of partition tables, in general, and is significantly more complex than the MBR scheme.



[[Category:Storage]]
[[Category:Storage]]

Revision as of 02:36, 22 January 2008

The following information about Partition Tables only applies to hard disk drives. Most other storage devices use other partitioning techniques, if they even use partitioning at all.

MBR

The Master Boot Record is the traditional way of storing partition information about a drive, along with some boot code. Almost all PCs still use an MBR for this purpose. You can find more information about the MBR boot process in MBR (x86). MBRs are nearly obsolete at this time, because of the 32 bit design of the LBA fields in the Partition Table. One possible replacement for the MBR system is GPT (see below).

Information about primary partitions and an extended partition is contained in the Partition Table, a 64-byte data structure located in the first sector (cylinder 0, head 0, sector 1 -- or, alternately, LBA 0) of the hard drive. The Partition Table conforms to a standard layout that is independent of the operating system. Each Partition Table entry is 16 bytes long, making a maximum of four entries available. Each entry starts at a predetermined offset from the beginning of the sector, as follows:

Partition number Offset
Partition 1 0x01BE (446)
Partition 2 0x01CE (462)
Partition 3 0x01DE (478)
Partition 4 0x01EE (494)

Each entry has the following structure:

Element Size Description
0 byte Boot indicator bit flags, 0 = no, 0x80 = bootable
1 byte Starting head
2 6 bits Starting sector (Bits 6-7 are the upper two bits for the Starting Cylinder field.)
3 10 bits Starting Cylinder
4 byte System ID
5 byte Ending Head
6 6 bits Ending Sector (Bits 6-7 are the upper two bits for the ending cylinder field)
7 10 bits Ending Cylinder
8 dword Relative Sector (to start of partition) (This field can be considered the partition's starting LBA value)
12 dword Total Sectors in partition

Please note: the Partition Table entries are not aligned on 4 byte boundaries, neither are the two dword LBA entry values -- so the LBA values cannot be copied directly into a register, if the MBR is itself loaded into memory on a 4 byte boundary. The Cylinder, Head, Sector fields (taken together) are only 3 bytes (28 bits) long. The ending CHS value of the partition must be stored in one of those 3 byte fields, and Sector values of 0 are illegal. This means that the CHS fields "max out" on a drive that is approximately 8GB in size -- and are therefore useless on almost all current drives. For a drive bigger than 8GB, generally the CHS fields are set to Cylinder = 1023, Head = 255, Sector = 63 -- which is considered an invalid setting. Since the two CHS fields are unused in all current large drives, the definition of an MBR could theoretically be modified to set a flag in the "bitflags" field, eliminate the two CHS fields, and then extend the "starting LBA" and partition sector count fields to be 48 bits long. This would allow MBR-type partition tables to be used with drives larger than 8TB.

GPT

GPT is an updated Partition Table standard, that has been adopted as the recommended partition mechanism under UEFI. It does not contain the artificial 28 bit or 32 bit limitations of the MBR Partition Tables. It also contains enhancements to the concept of partition tables, in general, and is significantly more complex than the MBR scheme.