https://wiki.archlinux.org/api.php?action=feedcontributions&user=Byassine52&feedformat=atomArchWiki - User contributions [en]2024-03-29T12:37:19ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=GUID_Partition_Table&diff=250732GUID Partition Table2013-03-15T05:17:27Z<p>Byassine52: /* Problems with MBR */</p>
<hr />
<div>[[Category:File systems]]<br />
[[es:GUID Partition Table]]<br />
[[tr:Guid_Bölümledirme_Tablosu]]<br />
[[zh-CN:GUID Partition Table]]<br />
{{Article summary start}}<br />
{{Article summary text|An overview of the GUID Partition Table.}}<br />
{{Article summary heading|Overview}}<br />
{{Article summary text|{{Boot process overview}}}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Unified Extensible Firmware Interface}}<br />
{{Article summary wiki|Master Boot Record}}<br />
{{Article summary wiki|Arch Boot Process}}<br />
{{Article summary end}}<br />
<br />
GUID Partition Table (GPT) is a new style of partitioning which is part of the [[Unified Extensible Firmware Interface]] Specification, using the [[Wikipedia:Globally unique identifier | 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.<br />
<br />
To understand GPT, it is important to understand what MBR is and what its disadvantages are.<br />
<br />
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.<br />
<br />
== Master Boot Record ==<br />
The MBR partition table stores the partitions info in the first sector of a hard disk as follows<br />
<br />
{| border="1"<br />
! Location in the HDD !! Purpose of the Code<br />
|-<br />
| First 440 bytes || MBR boot code that is launched by the BIOS.<br />
|-<br />
| 441-446 bytes || MBR disk signature.<br />
|-<br />
| 447-510 bytes || Actual partition table with info about primary and extended partitions. (Note that logical partitions are not listed here)<br />
|-<br />
| 511-512 bytes || MBR boot signature 0xAA55.<br />
|}<br />
<br />
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.<br />
<br />
=== Problems with MBR ===<br />
# 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.<br />
# 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.<br />
# MBR supports only 1 byte partition type codes which leads to many collisions.<br />
# 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.<br />
<br />
== GUID Partition Table ==<br />
GUID Partition Table (GPT) uses GUIDs (or UUIDs in linux world) to define partitions and its types, hence the name. The GPT consists of:<br />
{| border="1"<br />
! Location in the HDD !! Purpose<br />
|-<br />
| 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.<br />
|-<br />
| 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<br />
|-<br />
| 16 KiB (by default) following the second logical sector of the disk<br />
| 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.<br />
|-<br />
| 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.<br />
|-<br />
| 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.<br />
|}<br />
<br />
=== Advantages of GPT ===<br />
# Uses GUIDs (UUIDs) to identify partition types - No collisions.<br />
# Provides a unique disk GUID and unique partition GUID for each partition - A good filesystem-independent way of referencing partitions and disks.<br />
# 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).<br />
# Uses 64-bit LBA for storing Sector numbers - maximum addressable disk size is 2 ZiB.<br />
# Stores a backup header and partition table at the end of the disk that aids in recovery in case the primary ones are damaged.<br />
# CRC32 checksums to detect errors and corruption of the header and partition table.<br />
<br />
=== Kernel Support ===<br />
<br />
{{ic|CONFIG_EFI_PARTITION}} option in the kernel config enables GPT support in the kernel (despite the name EFI PARTITION). This options must be built-in the kernel and not compiled as a loadable module. This option is required even if GPT disks are used only for data storage and not for booting. This option is enabled by default in Arch's {{Pkg|linux}} and {{Pkg|linux-lts}} kernels in [core] repo. In case of a custom kernel enable this option by doing {{ic|1=CONFIG_EFI_PARTITION=y}}.<br />
<br />
== Bootloader Support ==<br />
<br />
=== UEFI systems ===<br />
<br />
All UEFI Bootloaders support GPT disks since GPT is a part of UEFI Specification and thus mandatory for UEFI boot. See [[UEFI_Bootloaders]] for more info.<br />
<br />
=== BIOS systems ===<br />
<br />
{{Note|Some BIOS systems may not boot from GPT disks. See http://mjg59.dreamwidth.org/8035.html and http://rodsbooks.com/gdisk/bios.html for more info and possible workarounds.}}<br />
<br />
* [[GRUB]](2) requires a 1007 KiB [[GRUB2#GUID_Partition_Table_.28GPT.29_specific_instructions|BIOS Boot Partition]] (EF02 type code in gdisk and bios_grub flag in GNU Parted) in BIOS systems to embed its {{ic|core.img}} file due to lack of post-MBR embed gap in GPT disks. Runtime GPT support in GRUB(2) is provided by the {{ic|part_gpt}} module.<br />
<br />
* [[Syslinux]] requires the partition containing {{ic|/boot/syslinux/ldlinux.sys}} (irrespective whether {{ic|/boot}} is a separate partition or not) to be marked as "Legacy BIOS Bootable" GPT attribute (''legacy_boot'' flag in GNU Parted) to identify the partition containing the Syslinux boot files by its 440-byte MBR boot code {{ic|gptmbr.bin}}. See [[Syslinux#GUID_Partition_Table_aka_GPT]] for more information. It is equivalent to "boot" flag in MBR disks.<br />
<br />
* [[GRUB Legacy]], present in the AUR as {{AUR|grub-legacy}}, does not support GPT disks. Fedora's heavily patched GRUB Legacy fork {{AUR|grub-legacy-fedora-git}} contains GPT patches from Intel (tested in Fedora, not tested in Arch).<br />
<br />
{{Note|Fedora developers have mentioned that after the release of Fedora 17, ''grub-legacy-fedora'' development will stop. Fedora already uses GRUB(2) as its default BIOS bootloader since F16. Users are recommended to switch to GRUB(2) or Syslinux instead.}}<br />
<br />
{{Note|Some Intel Desktop Board motherboards will only boot a GPT disk if the protective MBR partition has its Boot flag set. This can be done safely with fdisk/cfdisk without damaging the GPT (but have backups / double-check the integrity of the GPT afterwards anyway).}}<br />
<br />
* [[LILO]]'s GPT support has not been tested so it is unclear whether it has issues booting in GPT disks.<br />
<br />
== Partitioning Utilities ==<br />
=== GPT fdisk ===<br />
<br />
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 {{Pkg|gptfdisk}}.<br />
<br />
{{Note|The fdisk partitioning utilities from util-linux (i.e. fdisk, cfdisk and sfdisk) do not support GPT, and may damage the GPT header and partition table if used on a GPT disk.}}<br />
<br />
==== Convert from MBR to GPT ====<br />
<br />
One of the best features of gdisk (and sgdisk and cgdisk too) 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. <br />
<br />
Just open the MBR disk using gdisk and exit with "w" option to write the changes back to the disk (similar to fdisk) to convert the MBR disk to GPT. '''Watch out for any error and fix them before writing any change to disk''' because you may risk losing data. See http://www.rodsbooks.com/gdisk/mbr2gpt.html for more info. After conversion, the bootloaders will need to be reinstalled to configure them to boot from GPT.<br />
<br />
{{Note|Remember that GPT stores a secondary table at the end of disk. You must make sure that the last 1 MiB of the disk is not used by any partition.}}<br />
<br />
{{Note|Keep in mind that if your Boot-Manager is Grub, it needs a [[GRUB2#GPT_specific_instructions|BIOS Boot Partition]]. If your MBR Partitioning Layout isn't too old, there is a good chance that the first partition starts at sector 2048 for alignment reasons. That means at the beginning will be 1007KiB of empty space where this bios-boot partition can be created. To do this, first do the mbr->gpt conversion with gdisk as described above. Afterwards, create a new partition with gdisk and manually specify its position to be sectors 34 - 2047, and set the {{ic|EF02}} partition type.}}<br />
<br />
=== GNU Parted ===<br />
<br />
In GNU Parted >=3.0, the {{ic|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 external 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) for filesystem related operations.<br />
<br />
==See also==<br />
# Wikipedia's Page on [http://en.wikipedia.org/wiki/GUID_Partition_Table GPT] and [http://en.wikipedia.org/wiki/Master_boot_record MBR]<br />
# [http://rodsbooks.com/gdisk/ Homepage of Rod Smith's GPT fdisk tool] and its [http://sourceforge.net/projects/gptfdisk/ Sourceforge.net Project page - gptfdisk]<br />
# Rod Smith's page on [http://rodsbooks.com/gdisk/mbr2gpt.html Converting MBR to GPT] and [http://rodsbooks.com/gdisk/booting.html Booting OSes from GPT]<br />
# Rod Smith's page on the [http://www.rodsbooks.com/linux-fs-code/index.html New Partition Type GUID] for Linux data partitions<br />
# [http://sysresccd.org/Sysresccd-Partitioning-The-new-GPT-disk-layout System Rescue CD's page on GPT]<br />
# Wikipedia page on [http://en.wikipedia.org/wiki/BIOS_Boot_partition BIOS Boot Partition]<br />
# [http://www.ibm.com/developerworks/linux/library/l-gpt/index.html?ca=dgr-lnxw07GPT-Storagedth-lx&S_TACT=105AGY83&S_CMP=grlnxw07 Make the most of large drives with GPT and Linux - IBM Developer Works]<br />
# [http://www.microsoft.com/whdc/device/storage/GPT_FAQ.mspx Microsoft's Windows and GPT FAQ]</div>Byassine52