GUID Partition Table (GPT)
GPT - Technical Documentation
The GUID Partition Table, known as the GPT, is a popular disk partitioning scheme used across most operating systems, including Windows and Unix-class operating systems such as Mac OS X.
It was introduced by Intel in the late 1990's and has since become the standard layout of the partition table on a physical hard disk. It is a successor to many partition tables, such as MBR and APM, overcoming their limitations of using 32 bits for logical block addresses and a standard block size of 512 bytes.
These limitations restrict the disk size of the machine to 2.2TB. With the rate of increase in hard drive capacity in computers, this limitation is significant enough for switching most of the older partitioning schemes to the GPT, which allocates 64 bits for logical block addresses, translating to 9.4 ZB(zeta-bytes, or 9.4*10²¹ bytes) of potential capacity. With the entire World Wide Web being estimated to be about 0.5 ZB in size, the GPT partitioning system has the potential to stay around for a long time.
Figure 1 gives a scheme of the GPT:
Note: The green block represents the Primary GPT, the blue block represents the secondary GPT
The GPT, or the GUID Partition Table, is the standard format of partitioning tables on a physical hard disk. It was introduced as part of the EFI, or Extensible Firmware Interface, standard, created by Intel to replace the outlived BIOS, one of the last relics of the ancient IBM PC. The EFI uses the GPT where BIOS used the MBR.
Unlike the MBR, which starts with an executable program, called to identify and load the active sector, the GPT uses the wider range of possibilities of the EFI to start up these processes. However, the MBR is present at the beginning of the disk, in block LBA0, for protective and compatibility purposes. Strictly speaking, the GPT starts up from the Partition Table Header.
The GPT uses a modern system of Logical Block Addressing (LBA) rather than the outdated CHS (Cylinder-Head-Sector) method, used in MBR. Passed down from its predecessor, block LBA 0 contains MBR, with the Primary GPT Header in LBA 1. Following the GPT Header is the partition table itself. In the 64-bit version of Microsoft Windows NT, the GPT reserves the first 32 sectors, so that the first used sector on every hard drive is LBA 34.
That aside, the GPT provides data duplication; the header and partition table are stored both at the start and the end of the disk.
Theoretically, the GPT allows the partitioning of disks up to 9.4 ZB, while MBR works only up to 2.2 TB.
Protective MBR Block (LBA 0):
The main purpose of inserting the MBR at the start of disk is strictly for protection. MBR-oriented disk utilities have the possibility of not recognizing or even writing over top of the GPT disks. To prevent this, the entire GPT disk is labeled as one partition. The System ID of this partitoin is established as 0xEE, indicating the implementation of the GPT.
After this, the EFI ignores the MBR. Several 32-bit operating systems, not compatible with reading disks using the GPT scheme, still recognize the System ID and recognize the GPT disk as inaccessible, preventing the overwriting of the GPT disk.
Older operating systems often recognize the disk as containing a single partition of an unknown type, without free space; and therefore, as a rule of thumb, refuse to modify this type of disk unless the user specifically demands that this be done. This helps prevent the accidental deletion of contents on the GPT disk.
Primary GPT Header (LBA 1):
The GPT Header indicates the usable logical blocks on the disk. Also, it indicates the number and size records of the partitions, forming the partition table on a machine that contains the 64-bit version of Microsoft Windows Server 2003, 128 records of partition information are reserved, with each record being 128 bytes. This way, it is possible to create 128 partitions on the disk.
The GUID (Globally Unique Identifier) of the disk contains the header. Inside it is its' size and location (always block LBA 1), as well as the size and location of the secondary (emergency) header and partition table, always found in the last sectors of the disk.
As an important note, it also contains the Cyclic Redundancy Check CRC32 for itself and the partition table. It is run through an EFI process once the machine is started up. Because of the checksum, it is impossible to use disk Hex Editors to edit raw GPT data.
Any modifications to the GPT will change the checksum, after which the EFI will rewrite the primary GPT with the secondary one. If both of the GPTs hold an invalid checksum, access to the disk will become impossible.
The following table shows the GPT Header Format:
Partition Entries (LBA 2-33):
Partition entries are done simple and are done with equally incremented addresses. The first 16 bytes are used to define the GUID partition type. For example, the GUID EFI system appears as:
"C12A7328-F81F-11D2-BA4B-00A0C9 3EC93B", with the next 16 bytes containing a GUID that is unique to the partition. After that, there is the record of the start and end of the 64-bit LBA, if applicable. The rest of the space is dedicated to the names and attributes of the partition.
The following is an example of C++ structures that are used with the GPT: