Difference between revisions of "GUID Partition Table (简体中文)"
m (→BIOS systems)
m (→Master Boot Record)
|Line 25:||Line 25:|
! HDD的位置 !! 作用
! HDD的位置 !! 作用
| 前 440 个字节 ||
| 前 440 个字节 ||
| 441-446 字节 ||
| 441-446 字节 ||
| 447-510 字节 || 实际的主分区和扩展分区的分区表信息 。(
| 447-510 字节 || 实际的主分区和扩展分区的分区表信息 。()
| 511-512 字节 ||
| 511-512 字节 || 0xAA55。
Revision as of 03:44, 9 June 2013
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
|前 440 个字节||由BIOS锁存的MBR启动代码|
|447-510 字节||实际的主分区和扩展分区的分区表信息 。(注，此处未列出逻辑分区)|
|511-512 字节||MBR 启动标识 0xAA55。|
有64字节的空间用来描述主分区的信息。为了扩展它，启用了扩展分区的概念。 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.
- 一块磁盘只能存在 4 个主分区或者是最多 3 个主分区加上 1 个扩展分区（扩展分区里面可以建立任意数量的逻辑分区）。 如果你已经有 3 个主分区加上一个扩展分区，就算硬盘上还存在一些自由空间，你也不能在上面新建任何的分区。
- MBR分区扇区存储信息使用32位LBA值。LBA 使用扇区为 512 比特（较常用）导致 2 TiB 为的磁盘的最大寻址。如果使用 MBR 超过 2 TiB 的磁盘便不能被识别或者是分区。
GUID Partition Table（GPT 分区表）
GUID 分区表（GPT）使用 GUID 分区定义及其类型（Linux中叫做 UUID ），因此得名。GPT 分区表包括：
|磁盘的第一逻辑扇区或前 512 字节||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.|
|磁盘的第二个逻辑扇区或下一个 512 直接||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.|
|最后一个逻辑扇区或最后 512 字节||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
- 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 (maximum 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.
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 and kernels in [core] repo. In case of a custom kernel enable this option by doing
自从 GPT 成为 UEFI 规范的一部分且强制其为UEFI的引导,所有 UEFI 引导程序都支持GPT磁盘。 阅读 UEFI_Bootloaders 可以获得更多的信息。
- GRUB2 需要一个2 MiB 的“BIOS引导分区” （在 gdisk 中分区代码为 EF02，在 GNU Parted 中使用 bios_grub 标志）。in BIOS systems to embed its
core.imgfile due to lack of post-MBR embed gap in GPT disks. Runtime GPT support in GRUB2 is provided by the
part_gptmodule. See GRUB2#GPT specific instructions for more info.
- Syslinux requires the
/bootpartition 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
gptmbr.bin. See Syslinux#GUID_Partition_Table_aka_GPT for more info.
- GRUB Legacy, present in the AUR as AUR, does not support GPT disks. Fedora's heavily patched GRUB Legacy fork AUR contains GPT patches from Intel (tested in Fedora, not tested in Arch).
- LILO's GPT support has not been tested so it is unclear whether it has issues booting in GPT disks.
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 (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.
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.
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 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.
- 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
- Rod Smith's page on the New Partition Type GUID for Linux data partitions
- 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