Partition Table: Difference between revisions

Extending article
m (fixing tiny mistakes)
(Extending article)
Line 2: Line 2:


==MBR==
==MBR==
The Master Boot Record is the traditional way of storing partition information about a hard disk, 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).
The Master Boot Record is the traditional way of storing partition information about a hard disk, along with some boot code.
That is, the Partition Table is contained inside the [[MBR (x86)|MBR]], which is stored in the first sector
(cylinder 0, head 0, sector 1 -- or, alternately, LBA 0) of the hard drive.
(See the [[MBR (x86)|MBR article]] for the overall structure and contents of the MBR.)


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:
Almost all PCs still use an MBR for booting hard disks, and for storing partition information on hard disks.
Traditional MBRs are nearly obsolete at this time, because the 32 bit design of the LBA fields in the Partition Table begins
to "overflow" when dealing with disks larger than 2Tb.
One possible replacement for the MBR system is GPT (see below). It might also be possible to agree on a new standard for
the MBR, with 48 bit LBA fields for the partitions (see below).
 
Information about primary partitions and an extended partition is contained in a 64-byte data structure located in the MBR.
This 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 24: Line 36:
|}
|}


Each entry has the following structure:
Note: Naming the partition table entries as "1" through "4" is for convenience only.
The partition table entries are not required to be in any kind of order.
 
 
Each of the four Partition Table entries contains the following elements, in the following structure:


{| {{wikitable}}
{| {{wikitable}}
! Element
! Element (offset)
! Size
! Size
! Description
! Description
Line 33: Line 49:
| 0
| 0
| byte
| byte
| Boot indicator bit flags, 0 = no, 0x80 = bootable
| Boot indicator bit flag: 0 = no, 0x80 = bootable (or "active")
|-
|-
| 1
| 1
Line 72: Line 88:
|}
|}


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.
Notes:
The Cylinder, Head, Sector fields (taken together) are only 3 bytes (24 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.
* Any one of the partitions may be "active" (ie. bootable).
Since the two CHS fields are unused in all current large drives, the definition of an MBR could theoretically be modified to set an "alternate partition format" 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 beyond 8TB in size.
* At most one partition should be active.
* The Partition Table entries are <b>not</b> aligned on 4 byte boundaries (if the MBR is itself loaded into memory on a 4 byte boundary).
* Therefore, neither are the two dword LBA entry values -- so the LBA values cannot be copied directly into a register.
* The Cylinder, Head, Sector fields (taken together) are only 3 bytes (24 bits) long.
* Sector values (in the CHS fields) of 0 are illegal.
* CHS fields "max out" on a drive that is approximately 8GB in size -- and are therefore useless on almost all current drives.
* For drives smaller than 8GB, the LBA fields and the CHS fields must "match" when the values are converted into the other format.
* For drives bigger than 8GB, generally the CHS fields are set to Cylinder = 1023, Head = 255, Sector = 63 -- which is considered an invalid setting.
* If a Partition Table entry is unused, then it should be set to all 0.
* A System ID byte value of 0 is the definitive indicator for an unused entry.
* Any other illegal value (CHS Sector = 0 or Total Sectors = 0) may also indicate an unused entry.
 
===The System ID byte===
The System ID byte is supposed to indicate what filesystem is contained on the partition (ie. Ext2, ReiserFS, FAT32, NTFS, ...).
There was never any standard created for the System ID byte -- which means that Microsoft went and tried to hog almost all of the possible values.
See [[#External Links|the links below]] for tables of values of the System ID byte, for filesystems that have been lucky enough to aquire
their own value by common consensus.
 
If you create your own custom filesystem, then you can simply pick a System ID value for your filesystem that seems to be unused.
There is also an attempt to standardize the use of System ID value = 0x7f (by the Alt-OS gang), to cover all custom filesystems that follow the standard -- however, their effort seems to be losing steam.
 
=="Unofficial" 48 bit LBA Proposed MBR Format==
The two CHS fields are unused in all current drives, leaving only the two 32 bit LBA fields to "do all the work". But there never was any 32 bit
LBA addressing mode -- the current "standard" LBA addressing mode is 48 bits. So it is reasonable to try to redefine the Partition Table to eliminate the
unused CHS fields, and use the extra space to extend the two LBA fields to a full 48 bit size. This would eliminate the impending obsolescence
of the entire MBR scheme.
 
It seems reasonable to try to preserve (as much as possible) the current Partition Table structure. Therefore, the following alternate
structure for 48 bit LBA Partition Table entries is proposed:
 
{| {{wikitable}}
! Element (offset)
! Size
! Description
|-
| 0
| byte
| Bitflags field: 1 = not bootable, 0x81 = bootable (or "active")
|-
| 1
| byte
| (unused)
|-
| 2
| word
| Partition Start LBA (high word of 48 bit value)
|-
| 4
| byte
| System ID
|-
| 5
| byte
| (unused)
|-
| 6
| word
| Partition Length (high word of 48 bit value)
|-
| 8
| dword
| Partition Start LBA (low dword)
|-
| 12
| dword
| Partition Length (low dword)
|}
 
Note: The basic intent is to use bit #0 (value = 1) in the bitflags field as a "48 bit LBA" indicator, preserve the offsets and functions
of the bitflags and System ID fields, and use the two available aligned words to extend the LBA fields.


== GPT ==
== GPT ==
Line 81: Line 166:




==See Also==
===External Links===
* [http://www.win.tue.nl/~aeb/partitions/partition_types-1.html System ID byte values for known filesystems]
* [http://www.microsoft.com/whdc/device/storage/GPT-on-x64.mspx Microsoft's GPT info]
[[Category:x86]]
[[Category:Storage]]
[[Category:Storage]]
221

edits