Difference between revisions of "GUID Partition Table (简体中文)"

From ArchWiki
Jump to: navigation, search
(update interlanguage links)
(Tag: wiki-scripts)
 
(35 intermediate revisions by 11 users not shown)
Line 1: Line 1:
 
[[Category:File systems (简体中文)]]
 
[[Category:File systems (简体中文)]]
[[en:GUID Partition Table]]
+
[[ar:Partitioning]]
[[tr:Guid_Bölümledirme_Tablosu]]
+
[[el:GUID Partition Table]]
{{Article summary start}}
+
[[en:Partitioning]]
{{Article summary text|An overview of the GUID Partition Table.}}
+
[[es:GUID Partition Table]]
{{Article summary heading|Overview}}
+
[[hu:GUID Partition Table]]
{{Article summary text|{{Boot process overview}}}}
+
[[it:Partitioning]]
{{Article summary heading|Related}}
+
[[ja:GUID Partition Table]]
{{Article summary wiki|Unified Extensible Firmware Interface}}
+
[[pl:Partitioning]]
{{Article summary wiki|Master Boot Record}}
+
[[ru:Partitioning]]
{{Article summary wiki|Arch Boot Process}}
+
[[tr:Guid Bölümledirme Tablosu]]
{{Article summary end}}
+
{{Related articles start (简体中文)}}
{{Translateme (简体中文)}}  
+
{{Related|Arch boot process}}
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.
+
{{Related|Master Boot Record}}
 +
{{Related|Unified Extensible Firmware Interface}}
 +
{{Related|Partitioning}}
 +
{{Related articles end}}
 +
{{TranslationStatus (简体中文)|GUID_Partition_Table|2015-02-27|355829}}
  
To understand GPT, it is important to understand what is MBR and what are its disadvantages.
+
全局唯一标识分区表(GUID Partition Table,缩写:GPT)是一个实体硬盘的分区表的结构布局的标准。它是[[Unified Extensible Firmware Interface|统一可扩展固件接口]]标准的一部分,它使用[[Wikipedia:Globally unique identifier|全局唯一标识]]来标识设备。它是新一代分区表格式,用以解决 [[MBR]] 分区表的缺点,同时带来了一些优点。
  
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.
+
== 关于 GUID 分区表 ==
  
== Master Boot Record ==
+
全局唯一标识分区表 (GPT) 使用 GUID (或在 Linux 世界里称为 UUID) 来定义分区,它的类型和它的名称。GPT 组成如下:
The MBR partition table stores the partitions info in the first sector of a hard disk as follows
+
  
{| border="1"
+
{| class="wikitable"
! Location in the HDD !! Purpose of the Code
+
! HDD 上的位置 !! 用意
|-
+
|-
| First 440 bytes || MBR boot code that is launched by the BIOS.
+
| 硬盘的第一个逻辑扇区或者第一个512B || 保护分区 (Protective MBR) - 与一般 MBR 相同但是这个64B区域仅包含了一个类型为 0xEE 的主分区条目,它定义在整个硬盘上,或者大小为2TB的区域(如果硬盘超过2TB)。
|-
+
|-
| 441-446 bytes || MBR disk signature.
+
| 硬盘的第二个逻辑扇区或者第二个512B || 主 GPT 头 - 包含唯一硬盘 GUID, 主分区表的位置,分区表的可能条目数,它本身和主分区表的 CRC32 校验值,第二(或备份) GPT 头的位置
|-
+
|-
| 447-510 bytes || Actual partition table with info about primary and extended partitions. (Note that logical partitions are not listed here)
+
| 硬盘的第二个逻辑扇区之后的16 KB (默认)
|-
+
| 主 GPT 表 - 128个分区条目(默认,可以更高),每个包含大小为128B的条目(因此128个分区共占16KB)。扇区数存储为64位的 LBA 值,每个分区有一个分区类型 GUID 和一个唯一分区 GUID.
| 511-512 bytes || MBR boot signature 0xAA55.
+
|-
 +
| 硬盘最后一个扇区前的16 KB (默认) || 第二 GPT 表 - 与主表完全相同,主要用于主表损坏时的修复。
 +
|-
 +
| 硬盘最后一个逻辑扇区或者最后一个512B || 第二 GPT 头 - 包含唯一硬盘 GUID, 第二分区表的位置,分区表的可能条目数,它本身和第二分区表的 CRC32 校验值,主 GPT 头的位置。这个头用于当主头损坏时恢复 GPT 信息。
 
|}
 
|}
  
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.
+
=== GPT 的优点 ===
  
=== Problems with MBR ===
+
# 使用 GUID (UUID) 来表明分区类型 - 无冲突。
# 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.
+
# 为每个分区提供了一个唯一硬盘 GUID 和一个唯一分区 GUID - 一个好的不依赖文件系统的引用分区和硬盘的方式。
# 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.
+
# 任意分区数 - 取决于给分区表分配的空间 - 不需要扩展和逻辑分区。GPT ,默认包含了定义128个分区的空间。当用户想要更多分区时,他可以给分区表分配更多空间 (目前只有 gdisk 支持这一特性)。
# MBR supports only 1 byte partition type codes which leads to many collisions.
+
# 使用64位 LBA 存储扇区数 - 最大硬盘可寻址大小为 2 [[Wikipedia:ZiB|ZB]]. MBR 仅能支持最大 2 TiB 的磁盘。
# 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.
+
# 存储了备份头和分区表可于主要部分损坏时进行急救。
 +
# CRC32 校验值用于检测头和分区表的错误与损坏。
  
== 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:
+
{| border="1"
+
! 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 ===
+
内核配置选项 {{ic|CONFIG_EFI_PARTITION}} 启用了内核级 GPT 支持 (忽略它的名称 EFI PARTITION). 这个选项必须是内建在内核中并且不能编译为可加载模块。就算 GPT 硬盘仅用来存储数据而不是启动盘,也要打开这个选项。在 Arch [core] 源中的 {{Pkg|linux}} 和 {{Pkg|linux-lts}}的默认打开了这个选项。自定义内核可通过 {{ic|1=CONFIG_EFI_PARTITION=y}} 开启这个选项。
# Uses GUIDs (UUIDs) to identify partition types - No collisions.
+
# Provides a unique disk GUID and unique partition GUID for each partition - A good filesystem-independent way of referencing partitions and disks.
+
# Arbitary number of partitions - depends on space allocated for the partition table (minimum of 128 partitions) - 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 in case the primary ones are damaged.
+
# CRC32 checksums to detect errors and corruption of the header and partition table.
+
  
=== Kernel Support ===
+
== 引导器支持 ==
  
{{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}}.
+
=== UEFI 系统 ===
  
== Bootloader Support ==
+
因为 GPT 是 UEFI 标准的一部分,因此所有 UEFI 引导器都支持 GPT 硬盘,并是从 UEFI 启动的强制要求。更多信息见 [[Boot loaders]].
  
=== UEFI systems ===
+
=== BIOS 系统 ===
  
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.
+
尽管理论上 GPT 支持 BIOS 系统,但有时会无效甚至完全不兼容。技术上 BIOS 假设为只执行 MBR 上的代码,因此,保住了不同的分区方案的可能性。然而 BIOS 可能会执行其他的检查比如: 检查 MBR 完整性,甚至可能是对整个 MBR 分区表(尽管通常只是第一个分区)。如果在这种情况下,下面列出了一些该问题的解决方案。
  
=== BIOS systems ===
+
{{警告|对于 Windows 来说,'''不支持'''从 BIOS/GPT 分区方案启动。如果你已安装 Windows 在 BIOS/MBR 分区方案上,'''不要''' 转换驱动器到 GPT! 如果完成, Windows 会启动失败 - 与启动 Windows 的引导器无关。我们可以在 UEFI 模式里安装 Windows 或者使用 [[UEFI Bootloaders|UEFI bootloader]] (它使用 GPT), 或者还原/安装 Windows 到 BIOS/GPT 混合 MBR (见分区成例).}}
  
* [[GRUB2]] requires a 2 MiB "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 GRUB2 is provided by the {{ic|part_gpt}} module. See [[GRUB2#GPT specific instructions]] for more info.
+
支持 GPT/BIOS 分区方案的引导器:
  
* [[Syslinux]] requires the {{ic|/boot}} partition 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 MBR boot code {{ic|gptmbr.bin}} . See [[Syslinux#GUID_Partition_Table_aka_GPT]] for more info.
+
* [[GRUB#GUID_Partition_Table_.28GPT.29_specific_instructions|GRUB]]
 +
* [[Syslinux#GUID_partition_table|Syslinux]]
 +
* 不支持: [[GRUB Legacy]] and [[LILO]]
  
* [[GRUB-Legacy]] present in official repos as {{Pkg|grub}} and in AUR as {{AUR|grub-gfx}}, 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 Archlinux).
+
==== 解决方案 ====
  
{{Note|Fedora developers have mentioned that after the release of Fedora 17, grub-legacy-fedora development will stop. Fedora already uses GRUB2 as its default BIOS bootloader since F16. Users are recommended to switch to GRUB2 or Syslinux instead.}}
+
有一些从 BIOS/GPT 分区方案启动的解决办法,然而尝试这些之前尝试以引导器标准程序从 BIOS/GPT 启动。如果无效,这些可能帮到你。(完整版阅读 [http://www.rodsbooks.com/gdisk/bios.html#bios 这个]):
  
* [[LILO]]'s GPT support has not been tested so it is unclear whether it has issues booting in GPT disks.
+
* 在保护分区上设置 boot 参数 (类型为 0xEE). 可由 {{ic|parted /dev/sdX}} 和 {{ic|disk_toggle pmbr_boot}} 或 {{ic|1=sgdisk /dev/sdX --attributes=1:set:2}} 完成。
 +
* 确认没有 EFI 系统分区。
 +
* 创建混合 MBR. 这个是寻求可用 MBR 分区的 BIOS 所需要的 (见下面的例子)。
 +
* 重新计算保护分区中的 CHS (Cylinder/Head/Sector) 值。GPT 不需要这些值但是保护分区可能需要它们来校准以为测试它们的 BIOS 工作。
 +
* 有可用 MBR 表的第二块硬盘意味着有可执行保护分区上代码的 BIOS.
 +
* 自2011年以来,许多计算机如果 BIOS 选项支持的话可以从 EFI 启动。
  
== Partitioning Utilities ==
+
== 分区工具 ==
=== GPT fdisk ===
+
  
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}}.
+
=== fdisk gdisk ===
  
{{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.}}
+
参考 [[fdisk]]。
  
==== Convert from MBR to GPT ====
+
=== GNU Parted ===
  
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.  
+
[[GNU Parted]] 是创建和处理分区表的工具,可以使用交互模式或者作为 [[GParted]] 图形程序的后端. 同时支持 GPT MBR.
  
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.
+
It supports GPT as well as MBR.
  
{{Note|Remember that GPT stores a secondary table at the end of disk. You may have to make sure that the last 1 MiB of the disk is not used by any partition.}}
+
== 分区成例 ==
  
=== GNU Parted ===
+
=== gdisk basic ===
 +
 
 +
# gdisk /dev/sdX
 +
o  # create new empty GUID partition table
 +
n  # partition 1 [enter], from beginning [enter], to 100GiB [+100GiB], linux fs type [enter]
 +
n  # partition 2 [enter], from beginning [enter], to 108GiB [+8GiB],  linux swap    [8200]
 +
w  # write table to disk and exit
 +
 
 +
=== gdisk basic (以及混合 MBR) ===
 +
 
 +
{{提示|使用 MB, GB 来对齐 2048 扇区。}}
 +
 
 +
# gdisk /dev/sdX
 +
o  # create new empty GUID partition table
 +
n  # partition 1 [enter], from beginning [enter], to 100GiB [+100GiB], linux fs type [enter]
 +
n  # partition 2 [enter], from beginning [enter], to 108GiB [+8GiB],  linux swap    [8200]
 +
n  # partition 3 [enter], from beginning [enter],          [+1MiB],  linux fs type [enter]
 +
r  # recovery/transformation menu
 +
h  # make hybrid mbr
 +
3  # add partition 3 to hybrid mbr
 +
Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): '''N'''
 +
Enter an MBR hex code (default 83): [enter]
 +
Set the bootable flag? (Y/N): Y
 +
Unused partition space(s) found. Use one to protect more partitions? (Y/N): N
 +
w  # write table to disk and exit
 +
 
 +
=== parted basic (通过命令行选项) ===
 +
 
 +
parted --script /dev/sda mklabel gpt
 +
parted --script --align optimal /dev/sda mkpart primary ext4 0% -8GiB mkpart primary linux-swap -8GiB 100%
 +
 
 +
=== sgdisk basic (自动搜寻) ===
 +
 
 +
得到'''硬盘空间''' (disk space) 和'''交换空间''' (swap space) 的值,然后设置'''根分区''' (root partition) 空间。
 +
 
 +
* '''硬盘空间''''''下舍入'''到最近的MB数值,头 GPT 元数据被扣除 (1 MB).
 +
* '''交换空间''''''上舍入'''到基于内存大小的MB数值。
 +
 
 +
diskspace=$(( $(grep sda$ /proc/partitions | awk '{print $3}') * 2 / 2048 - 1 ))
 +
swapspace=$(( $(head -n1 /proc/meminfo | awk '{print $2}') / 1024 + 1 ))
 +
rootspace=$(( $diskspace - $swapspace ))
 +
 
 +
运行这个 (这只是测试用'''模拟'''运行,删掉 '''--pretend''' 来写入分区表):
 +
 
 +
sgdisk --clear --new 1:0:+${rootspace}MiB --new 2:0:+${swapspace}MiB --typecode 2:8200 --pretend --print /dev/sda
  
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.
+
== 另见 ==
  
==See also==
+
# Wikipedia's  Page on [[wikipedia:GUID_Partition_Table|GPT]] and [[wikipedia:Master_boot_record|MBR]]
# Wikipedia's  Page on [http://en.wikipedia.org/wiki/GUID_Partition_Table GPT] and [http://en.wikipedia.org/wiki/Master_boot_record MBR]
+
 
# [http://rodsbooks.com/gdisk/ Homepage of Rod Smith's GPT fdisk tool] and its [http://sourceforge.net/projects/gptfdisk/ Sourceforge.net Project page - gptfdisk]
 
# [http://rodsbooks.com/gdisk/ Homepage of Rod Smith's GPT fdisk tool] and its [http://sourceforge.net/projects/gptfdisk/ Sourceforge.net Project page - gptfdisk]
# 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]
+
# Rod Smith's page on [http://www.rodsbooks.com/gdisk/whatsgpt.html What's a GPT?] [http://rodsbooks.com/gdisk/mbr2gpt.html Converting MBR to GPT] and [http://rodsbooks.com/gdisk/booting.html Booting OSes from GPT]
 
# Rod Smith's page on the [http://www.rodsbooks.com/linux-fs-code/index.html New Partition Type GUID] for Linux data partitions
 
# Rod Smith's page on the [http://www.rodsbooks.com/linux-fs-code/index.html New Partition Type GUID] for Linux data partitions
 
# [http://sysresccd.org/Sysresccd-Partitioning-The-new-GPT-disk-layout System Rescue CD's page on GPT]
 
# [http://sysresccd.org/Sysresccd-Partitioning-The-new-GPT-disk-layout System Rescue CD's page on GPT]
# Wikipedia page on [http://en.wikipedia.org/wiki/BIOS_Boot_partition BIOS Boot Partition]
+
# Wikipedia page on [[wikipedia:BIOS_Boot_partition|BIOS Boot Partition]]
 
# [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]
 
# [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]
 
# [http://www.microsoft.com/whdc/device/storage/GPT_FAQ.mspx Microsoft's Windows and GPT FAQ]
 
# [http://www.microsoft.com/whdc/device/storage/GPT_FAQ.mspx Microsoft's Windows and GPT FAQ]
 +
# Fedora developer discussion on [http://mjg59.dreamwidth.org/8035.html BIOS/GPT configuration]

Latest revision as of 14:53, 11 September 2016

翻译状态: 本文是英文页面 GUID_Partition_Table翻译,最后翻译时间:2015-02-27,点击这里可以查看翻译后英文页面的改动。

全局唯一标识分区表(GUID Partition Table,缩写:GPT)是一个实体硬盘的分区表的结构布局的标准。它是统一可扩展固件接口标准的一部分,它使用全局唯一标识来标识设备。它是新一代分区表格式,用以解决 MBR 分区表的缺点,同时带来了一些优点。

关于 GUID 分区表

全局唯一标识分区表 (GPT) 使用 GUID (或在 Linux 世界里称为 UUID) 来定义分区,它的类型和它的名称。GPT 组成如下:

HDD 上的位置 用意
硬盘的第一个逻辑扇区或者第一个512B 保护分区 (Protective MBR) - 与一般 MBR 相同但是这个64B区域仅包含了一个类型为 0xEE 的主分区条目,它定义在整个硬盘上,或者大小为2TB的区域(如果硬盘超过2TB)。
硬盘的第二个逻辑扇区或者第二个512B 主 GPT 头 - 包含唯一硬盘 GUID, 主分区表的位置,分区表的可能条目数,它本身和主分区表的 CRC32 校验值,第二(或备份) GPT 头的位置
硬盘的第二个逻辑扇区之后的16 KB (默认) 主 GPT 表 - 128个分区条目(默认,可以更高),每个包含大小为128B的条目(因此128个分区共占16KB)。扇区数存储为64位的 LBA 值,每个分区有一个分区类型 GUID 和一个唯一分区 GUID.
硬盘最后一个扇区前的16 KB (默认) 第二 GPT 表 - 与主表完全相同,主要用于主表损坏时的修复。
硬盘最后一个逻辑扇区或者最后一个512B 第二 GPT 头 - 包含唯一硬盘 GUID, 第二分区表的位置,分区表的可能条目数,它本身和第二分区表的 CRC32 校验值,主 GPT 头的位置。这个头用于当主头损坏时恢复 GPT 信息。

GPT 的优点

  1. 使用 GUID (UUID) 来表明分区类型 - 无冲突。
  2. 为每个分区提供了一个唯一硬盘 GUID 和一个唯一分区 GUID - 一个好的不依赖文件系统的引用分区和硬盘的方式。
  3. 任意分区数 - 取决于给分区表分配的空间 - 不需要扩展和逻辑分区。GPT ,默认包含了定义128个分区的空间。当用户想要更多分区时,他可以给分区表分配更多空间 (目前只有 gdisk 支持这一特性)。
  4. 使用64位 LBA 存储扇区数 - 最大硬盘可寻址大小为 2 ZB. MBR 仅能支持最大 2 TiB 的磁盘。
  5. 存储了备份头和分区表可于主要部分损坏时进行急救。
  6. CRC32 校验值用于检测头和分区表的错误与损坏。

内核支持

内核配置选项 CONFIG_EFI_PARTITION 启用了内核级 GPT 支持 (忽略它的名称 EFI PARTITION). 这个选项必须是内建在内核中并且不能编译为可加载模块。就算 GPT 硬盘仅用来存储数据而不是启动盘,也要打开这个选项。在 Arch [core] 源中的 linuxlinux-lts的默认打开了这个选项。自定义内核可通过 CONFIG_EFI_PARTITION=y 开启这个选项。

引导器支持

UEFI 系统

因为 GPT 是 UEFI 标准的一部分,因此所有 UEFI 引导器都支持 GPT 硬盘,并是从 UEFI 启动的强制要求。更多信息见 Boot loaders.

BIOS 系统

尽管理论上 GPT 支持 BIOS 系统,但有时会无效甚至完全不兼容。技术上 BIOS 假设为只执行 MBR 上的代码,因此,保住了不同的分区方案的可能性。然而 BIOS 可能会执行其他的检查比如: 检查 MBR 完整性,甚至可能是对整个 MBR 分区表(尽管通常只是第一个分区)。如果在这种情况下,下面列出了一些该问题的解决方案。

警告: 对于 Windows 来说,不支持从 BIOS/GPT 分区方案启动。如果你已安装 Windows 在 BIOS/MBR 分区方案上,不要 转换驱动器到 GPT! 如果完成, Windows 会启动失败 - 与启动 Windows 的引导器无关。我们可以在 UEFI 模式里安装 Windows 或者使用 UEFI bootloader (它使用 GPT), 或者还原/安装 Windows 到 BIOS/GPT 混合 MBR (见分区成例).

支持 GPT/BIOS 分区方案的引导器:

解决方案

有一些从 BIOS/GPT 分区方案启动的解决办法,然而尝试这些之前尝试以引导器标准程序从 BIOS/GPT 启动。如果无效,这些可能帮到你。(完整版阅读 这个):

  • 在保护分区上设置 boot 参数 (类型为 0xEE). 可由 parted /dev/sdXdisk_toggle pmbr_bootsgdisk /dev/sdX --attributes=1:set:2 完成。
  • 确认没有 EFI 系统分区。
  • 创建混合 MBR. 这个是寻求可用 MBR 分区的 BIOS 所需要的 (见下面的例子)。
  • 重新计算保护分区中的 CHS (Cylinder/Head/Sector) 值。GPT 不需要这些值但是保护分区可能需要它们来校准以为测试它们的 BIOS 工作。
  • 有可用 MBR 表的第二块硬盘意味着有可执行保护分区上代码的 BIOS.
  • 自2011年以来,许多计算机如果 BIOS 选项支持的话可以从 EFI 启动。

分区工具

fdisk 和 gdisk

参考 fdisk

GNU Parted

GNU Parted 是创建和处理分区表的工具,可以使用交互模式或者作为 GParted 图形程序的后端. 同时支持 GPT 和 MBR.

It supports GPT as well as MBR.

分区成例

gdisk basic

# gdisk /dev/sdX
o  # create new empty GUID partition table
n  # partition 1 [enter], from beginning [enter], to 100GiB [+100GiB], linux fs type [enter]
n  # partition 2 [enter], from beginning [enter], to 108GiB [+8GiB],   linux swap    [8200]
w  # write table to disk and exit

gdisk basic (以及混合 MBR)

提示: 使用 MB, GB 来对齐 2048 扇区。
# gdisk /dev/sdX
o  # create new empty GUID partition table
n  # partition 1 [enter], from beginning [enter], to 100GiB [+100GiB], linux fs type [enter]
n  # partition 2 [enter], from beginning [enter], to 108GiB [+8GiB],   linux swap    [8200]
n  # partition 3 [enter], from beginning [enter],           [+1MiB],   linux fs type [enter]
r  # recovery/transformation menu
h  # make hybrid mbr
3  # add partition 3 to hybrid mbr
Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): N
Enter an MBR hex code (default 83): [enter]
Set the bootable flag? (Y/N): Y
Unused partition space(s) found. Use one to protect more partitions? (Y/N): N
w  # write table to disk and exit

parted basic (通过命令行选项)

parted --script /dev/sda mklabel gpt
parted --script --align optimal /dev/sda mkpart primary ext4 0% -8GiB mkpart primary linux-swap -8GiB 100%

sgdisk basic (自动搜寻)

得到硬盘空间 (disk space) 和交换空间 (swap space) 的值,然后设置根分区 (root partition) 空间。

  • 硬盘空间'下舍入'到最近的MB数值,头 GPT 元数据被扣除 (1 MB).
  • 交换空间'上舍入'到基于内存大小的MB数值。
diskspace=$(( $(grep sda$ /proc/partitions | awk '{print $3}') * 2 / 2048 - 1 ))
swapspace=$(( $(head -n1 /proc/meminfo | awk '{print $2}') / 1024 + 1 ))
rootspace=$(( $diskspace - $swapspace ))

运行这个 (这只是测试用模拟运行,删掉 --pretend 来写入分区表):

sgdisk --clear --new 1:0:+${rootspace}MiB --new 2:0:+${swapspace}MiB --typecode 2:8200 --pretend --print /dev/sda

另见

  1. Wikipedia's Page on GPT and MBR
  2. Homepage of Rod Smith's GPT fdisk tool and its Sourceforge.net Project page - gptfdisk
  3. Rod Smith's page on What's a GPT? Converting MBR to GPT and Booting OSes from GPT
  4. Rod Smith's page on the New Partition Type GUID for Linux data partitions
  5. System Rescue CD's page on GPT
  6. Wikipedia page on BIOS Boot Partition
  7. Make the most of large drives with GPT and Linux - IBM Developer Works
  8. Microsoft's Windows and GPT FAQ
  9. Fedora developer discussion on BIOS/GPT configuration