Trisha Shetty (Editor)

GUID Partition Table

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit
GUID Partition Table

GUID Partition Table (GPT) is a standard for the layout of the partition table on a physical storage device used in a desktop or server PC, such as a hard disk drive or solid-state drive, using globally unique identifiers (GUID). Although it forms a part of the Unified Extensible Firmware Interface (UEFI) standard (Unified EFI Forum proposed replacement for the PC BIOS), it is also used on some BIOS systems because of the limitations of master boot record (MBR) partition tables, which use 32 bits for storing logical block addresses (LBA) and size information on a traditionally 512 byte disk sector.

Contents

All modern PC operating systems support GPT. Some, including macOS and Microsoft Windows on x86, support booting from GPT partitions only on systems with EFI firmware, but FreeBSD and most Linux distributions can boot from GPT partitions on systems with both legacy BIOS firmware interface and EFI.

History

The widespread MBR partitioning scheme, dating from the early 1980s, imposed limitations that affect the use of modern hardware. One of the main limitations is the usage of 32 bits for storing block addresses and quantity information. For hard disks with 512-byte sectors, the MBR partition table entries allow up to a maximum of 2 TiB (232 × 512 bytes).

Intel therefore developed a new partition table format in the late 1990s as part of what eventually became UEFI. As of 2010, GPT forms a subset of the UEFI specification. GPT allocates 64 bits for logical block addresses, therefore allowing a maximum disk size of 264 sectors. For disks with 512-byte sectors, maximum size is 9.4 ZB (9.4 × 1021 bytes) or 8 ZiB (9,444,732,965,739,290,427,392 bytes, coming from 18,446,744,073,709,551,616 (264) sectors × 512 (29) bytes per sector).

Features

MBR-based partition table schemes insert the partitioning information for (usually) four "primary" partitions in the MBR (which on a BIOS system is also the container for code that begins the process of booting the system). In a GPT, the first sector of the disk is reserved for a "protective MBR" such that booting a BIOS-based computer from a GPT disk is supported, but the bootloader and operating system must both be GPT-aware. Regardless of the sector size, the GPT header begins on the second logical block of the device.

Like modern MBRs, GPTs use logical block addressing (LBA) in place of the historical cylinder-head-sector (CHS) addressing. The protective MBR is contained in LBA 0, the GPT header is in LBA 1, and the GPT header has a pointer to the partition table, or Partition Entry Array, typically LBA 2. The UEFI specification stipulates that a minimum of 16,384 bytes, regardless of sector size, be allocated for the Partition Entry Array. On a disk having 512-byte sectors, a partition entry array size of 16,384 bytes and the minimum size of 128 bytes for each partition entry, LBA 34 is the first usable sector on the disk.

Hard-disk manufacturers are transitioning to 4,096-byte sectors. The first such drives continued to present 512-byte physical sectors to the OS, so degraded performance could result when the drive's physical 4 KB sector boundaries did not coincide with the 4 KB logical blocks, clusters and virtual memory pages common in many operating systems and file systems. This was a particular problem on writes, when the drive is forced to perform two read-modify-write operations to satisfy a single misaligned 4 KB write operation.

For backward compatibility with most legacy operating systems such as DOS, OS/2, and versions of Windows before Vista, MBR partitions must always start on track boundaries according to the traditional CHS addressing scheme and end on a cylinder boundary. This is also true of partitions with emulated CHS geometries (as reflected by the BIOS and the CHS sectors entries in the MBR partition table) or partitions accessed only via LBA. Extended partitions must start on cylinder boundaries as well. This typically causes the first primary partition to start at LBA 63 on disks accessed via LBA, leaving a gap of 62 sectors with MBR-based disks, sometimes called "MBR gap", "boot track", or "embedding area". That otherwise unused disk space is commonly used by bootloaders such as GRUB for storing their second stages.

Protective MBR (LBA 0)

For limited backward compatibility, the space of the legacy MBR is still reserved in the GPT specification, but it is now used in a way that prevents MBR-based disk utilities from misrecognizing and possibly overwriting GPT disks. This is referred to as a protective MBR.

A single partition type of EEh, encompassing the entire GPT drive (where "entire" actually means as much of the drive as can be represented in an MBR), is indicated and identifies it as GPT. Operating systems and tools which cannot read GPT disks will generally recognize the disk as containing one partition of unknown type and no empty space, and will typically refuse to modify the disk unless the user explicitly requests and confirms the deletion of this partition. This minimizes accidental erasures. Furthermore, GPT-aware OSes may check the protective MBR and if the enclosed partition type is not of type EEh or if there are multiple partitions defined on the target device, the OS may refuse to manipulate the partition table.

While the MBR and protective MBR layouts were defined around 512 bytes per sector, the actual sector size can be larger on various media such as MO disks or hard disks with Advanced Format. Extra space in the MBR typically remains unused.

If the actual size of the disk exceeds the maximum partition size representable using the legacy 32-bit LBA entries in the MBR partition table, the recorded size of this partition is clipped at the maximum, thereby ignoring the rest of disk. This amounts to a maximum reported size of 2 TB, assuming a disk with 512 bytes per sector (see 512e). It would result in 16 TB with 4 KB sectors (4Kn), but since many older operating systems and tools are hard wired for a sector size of 512 bytes or are limited to 32-bit calculations, exceeding the 2 TB limit could cause compatibility problems.

Hybrid MBR (LBA 0 + GPT)

In operating systems that support GPT-based boot through BIOS services rather than EFI, the first sector is also still used to store the first stage of the bootloader code, but modified to recognize GPT partitions. The bootloader in the MBR must not assume a sector size of 512 bytes.

Partition table header (LBA 1)

The partition table header defines the usable blocks on the disk. It also defines the number and size of the partition entries that make up the partition table. The EFI stipulates a minimum of 16,384 bytes be reserved for the partition table array, so there are 128 partition entries reserved, each 128 bytes long.

The header contains the disk GUID. It records its own size and location (always LBA 1) and the size and location of the secondary GPT header and table (always the last sectors on the disk). Importantly, it also contains a CRC32 checksum for itself and for the partition table, which may be verified by the firmware, bootloader, or operating system on boot. Because of this, hex editors should not be used to modify the contents of the GPT. Such modification would render the checksum invalid. In this case, the primary GPT may be overwritten with the secondary one by disk recovery software. If both GPTs contain invalid checksums, many bootloaders (those governed by an integrity model in particular) and operating systems will refuse to work with the disk until the corrupted partition tables are repaired or removed.

The values for current and backup LBAs of the primary header should be the second sector of the disk (LBA 1) and the last sector of the disk, respectively. The secondary header at the end of the disk identifies its own table of partition entries, which is located directly before that header.

Since the primary header must be located at LBA 1, it will not necessarily be physically contiguous with the MBR; on an Advanced Format disk with 4 KB sectors, the header will be located at the byte 4096 from the beginning of the disk, leaving a gap of unused space between it and the MBR. On such a disk, the byte 512 that directly follows the MBR is still part of LBA 0. However, a disk with 512-byte sectors will store its GPT header at byte 512 because, as such, that position corresponds to LBA 1.

Partition entries

After the header, the Partition Entry Array describes partitions, using a minimum size of 128 bytes for each entry block. The starting location of the array on disk, and the size of each entry, are given in the GPT header. The first 16 bytes of each entry designate the partition type's globally unique identifier (GUID). For example, the GUID for an EFI system partition is C12A7328-F81F-11D2-BA4B-00A0C93EC93B. The second 16 bytes are a GUID unique to the partition. Then follow the starting and ending 64 bit LBAs, partition attributes, and the 36 character (max) Unicode partition name. As is the nature and purpose of GUIDs, no central registry is needed to ensure the uniqueness of the GUID partition type designators.

Also, the sector size must not be assumed to be hard-wired to 512 bytes per sector in calculations (see Advanced Format), that is, there can be more than four partition entries in a single sector, and (with much larger partition table entries possible in the future) it is possible to have a sector hold only a fraction of a partition entry. Except for the first two sectors (LBA 0 and LBA 1), the GPT specification describes the size and organization of a data structure, but intentionally does not specify the number of sectors on disk that are used to store it.

The 64-bit partition table attributes are shared between 48-bit common attributes for all partition types, and 16-bit type-specific attributes:

Microsoft defines the type-specific attributes for basic data partition as:

Operating-system support

Hybrid MBRs are non-standard and can be interpreted in different ways by different operating systems. Unless otherwise noted, operating systems provide precedence to the GPT data when a hybrid MBR configuration is encountered.

Windows: 32-bit versions

Windows 7 and earlier do not support UEFI on 32-bit platforms, and therefore do not allow booting from GPT partitions.

References

GUID Partition Table Wikipedia