GUID Partition Table
Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary end
GUID Partition Table (GPT) is a new style of partitioning which is part of the Unified Extensible Firmware Interface Specification, using the globally unique identifier for devices. It is different from the Master Boot Record (the more commonly used partitioning style) in many aspects and has many advantages.
To understand GPT, it is important to understand what is MBR and what are its disadvantages.
For any partitioning style, the number of partitions that can be defined is based on the total space allotted for the partition table and the space required for storing the information of a single partition.
Master Boot Record
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|
|First 440 bytes||MBR boot code that is launched by the BIOS.|
|441-446 bytes||MBR disk signature.|
|447-510 bytes||Actual partition table with info about primary and extended partitions. (Note that logical partitions are not listed here)|
|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
- Only 4 primary partitions or 3 primary + 1 extended partitions with many logical partitions 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 space.
- 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 is lost.
- MBR supports only 1 byte partition type codes which leads to many collisions.
- 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 2TB. Any space beyond 2TB cannot be defined in a partition if MBR partitioning is used.
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 a:
|Location in the HDD||Purpose|
|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 TB, upto a partition size of 2 TB.|
|Next 512 bytes||Primary GPT Header - Contains the Unique Disk GUID, Location of the Primary Partition Table, No. of possible entries in the partition table, CRC32 checksums of itself and the Primary Partition Table, Location of the Secondary (or Backup) GPT Header|
|Next 16 KB (by default)||Primary GPT Table - 128 Partition entries each with each entry of size 128 byte (hence 16 KB). This size can be changed to accommodate more table entries (>128) and it can also be reduced (but UEFI Spec requires space for minimum of 128 table entries which is 16 KB). Sector numbers are stored as 64-bit LBA and each partition has a Partition type GUID and a Unique Partition GUID.|
|16 KB (minus 512 bytes) from the end||Secondary GPT table - It is byte-for-byte identical to the Primary table. Used mainly for recovery operations.|
|Last 512 bytes||Secondary GPT Header - Contains the Unique Disk GUID, Location of the Secondary Partition Table, No. 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
- Uses GUIDs to identify partition types - No collisions.
- Provides a unique disk GUID and partition GUID for each partition - A good filesystem-independent way of referencing partitions and disks.
- Minimum of 128 partition table entries - No need for extended and logical partitions.
- Uses 64-bit LBA for storing Sector numbers - maximum addressable disk size is 2 ZiB.
- Stores a backup header and partition table at the end of the disk that aids in recovery if the main copy is clobbered.
- CRC32 checksums to detect errors and corruption of the partition table.
The kernel's CONFIG_EFI_PARTITION option must be set to 'y' to compile EFI partition support into the kernel; 'm', for a loadable module, is not sufficient. CONFIG_EFI_PARTITION is enabled (i.e. set to CONFIG_EFI_PARTITION=y) by default in the Arch default kernel; if you are running a different kernel, you can use
zgrep CONFIG_EFI_PARTITION /proc/config.gz to check for this setting. This option is required even if GPT-formatted disks are used only for storing data and not for booting linux.
GRUB2 provides the ability to boot from GPT in both BIOS and UEFI based systems. All partition defining commands remain the same ( like (hd0,8) ). Just load the part_gpt grub2 module from grub2 shell or include "
insmod part_gpt" line before "
set root=" line in
grub.cfg file. Usually grub-probe will automatically add this module to the
grub.efi file if it detects the HDD to be using GPT.
To enable GRUB2 to embed the
core.img file in GPT disks for BIOS based systems, a BIOS boot partition of about 1 MB (no filesystem) is required. See GRUB2#GPT specific instructions on how to create it.
For Syslinux and Extlinux GPT support refer to Syslinux#GUID_Partition_Table_aka_GPT.
GPT fdisk is a set of text-mode utilities for editing GPT disks. It consists of gdisk,sgdisk and cgdisk which are equivalent to respective tools from util-linux fdisk (used for MBR disks). It is available in the [extra] repository as.
Convert from MBR to GPT
One of the best features of gdisk is its ability to convert MBR and BSD disklabels to GPT without data loss. Upon conversion, all the MBR primary partitions and the logical partitions become GPT partitions with the correct partition type GUIDs and Unique partition GUIDs created for each partition.
Just open the MBR disk using gdisk: Watch out for any error and fix them before writing any change to disk because you may risk losing data Doc for gdisk ! Exit with "w" option to write the changes back to the disk (similar to fdisk) to convert the MBR disk to GPT. After conversion, the bootloaders will need to be reinstalled to configure them to boot from GPT.
In GNU Parted >=3.0, the
parted command-line utility does not support any filesystem related operation, and most of the FS related code has been removed from the libparted, leaving only minimal code required by extrenal applications like gparted. The upstream recommends using the filesystem specific tools or one of the parted's GUI wrappers like gparted (which calls these external tools) to do FS related operations.
- Wikipedia's Page on GPT and MBR
- Homepage of Rod Smith's GPT fdisk tool and its Sourceforge.net Project page - gptfdisk
- Rod Smith's page on Converting MBR to GPT and Booting OSes from GPT
- System Rescue CD's page on GPT
- Wikipedia page on BIOS Boot Partition
- Make the most of large drives with GPT and Linux - IBM Developer Works
- Microsoft's Windows and GPT FAQ