UEFI setup, Ubuntu and Windows UEFI Dual Boot, Linux, Debian, Ubuntu, Fedora, Arch Linux

Monday 26 January 2015

GUID Partition Table

Monday, January 26, 2015 Posted by UEFI Support , , , ,
GUID Partition Table (GPT) is a partitioning scheme that is part of the Unified Extensible Firmware Interface specification; it uses a globally unique identifier for qualifying devices. It is the next generation partitioning scheme designed to succeed the Master Boot Record partitioning scheme method. Its necessity evolved to deal with several shortcomings the MBR partitioning scheme method and offers additional advantages.

About the Master Boot Record

To understand GPT it is important to understand what MBR is and what its disadvantages are. The MBR partition table stores the partitions info in the first sector of a hard disk as follows:
Location in the HDD Purpose of the Code
001-440 bytes MBR boot code that is launched by the BIOS.
441-446 bytes MBR disk signature.
447-510 bytes Partition table (of primary and extended partitions, not logical).
511-512 bytes MBR boot signature 0xAA55.
The entire information about the primary partitions is limited to the 64 bytes allotted. To extend this, extended partitions were used. An extended partition is simply a primary partition in the MBR which acts like a container for other partitions called logical partitions. So one is limited to either 4 primary partitions, or 3 primary and 1 extended partitions with many logical partitions inside it.

Problems with MBR

  1. Only 4 primary partitions or 3 primary + 1 extended partitions (with arbitrary number of logical partitions within the extended partition) can be defined. If you have 3 primary + 1 extended partitions, and you have some free space outside the extended partition area, you cannot create a new partition over that free space.
  2. Within the extended partition, the logical partitions' meta-data is stored in a linked-list structure. If one link is lost, all the logical partitions following that metadata are lost.
  3. MBR supports only 1 byte partition type codes which leads to many collisions.
  4. MBR stores partition sector information using 32-bit LBA values. This LBA length along with 512 byte sector size (more commonly used) limits the maximum addressable size of the disk to be 2 TiB. Any space beyond 2 TiB cannot be defined as a partition if MBR partitioning is used.

About the GUID Partition Table

GUID Partition Table (GPT) uses GUIDs (or UUIDs in linux world) to define partitions and its types, hence the name. The GPT consists of:
Location in the HDD Purpose
First logical sector of the disk or First 512 bytes Protective MBR - Same as a normal MBR but the 64-byte area contains a single 0xEE type Primary partition entry defined over the entire size of the disk or in case of >2 TiB, upto a partition size of 2 TiB.
Second logical sector of the disk or Next 512 bytes Primary GPT Header - Contains the Unique Disk GUID, Location of the Primary Partition Table, Number of possible entries in partition table, CRC32 checksums of itself and the Primary Partition Table, Location of the Secondary (or Backup) GPT Header
16 KiB (by default) following the second logical sector of the disk Primary GPT Table - 128 Partition entries (by default, can be higher), each with an entry of size 128 bytes (hence total of 16 KiB for 128 partition entries). Sector numbers are stored as 64-bit LBA and each partition has a Partition Type GUID and a Unique Partition GUID.
16 KiB (by default) before the last logical sector of the disk Secondary GPT table - It is byte-for-byte identical to the Primary table. Used mainly for recovery in case the primary partition table is damaged.
Last logical sector of the disk or Last 512 bytes Secondary GPT Header - Contains the Unique Disk GUID, Location of the Secondary Partition Table, Number of possible entries in the partition table, CRC32 checksums of itself and the Secondary Partition Table, Location of the Primary GPT Header. This header can be used to recover GPT info in case the primary header is corrupted.

Advantages of GPT

  1. Uses GUIDs (UUIDs) to identify partition types - No collisions.
  2. Provides a unique disk GUID and unique partition GUID for each partition - A good filesystem-independent way of referencing partitions and disks.
  3. Arbitrary number of partitions - depends on space allocated for the partition table - No need for extended and logical partitions. By default the GPT table contains space for defining 128 partitions. However if the user wants to define more partitions, he/she can allocate more space to the partition table (currently only gdisk is known to support this feature).
  4. Uses 64-bit LBA for storing Sector numbers - maximum addressable disk size is 2 ZiB.
  5. Stores a backup header and partition table at the end of the disk that aids in recovery in case the primary ones are damaged.
  6. CRC32 checksums to detect errors and corruption of the header and partition table.