我是靠谱客的博主 自觉夏天,最近开发中收集的这篇文章主要介绍GUID partition table (part of EFI) vs MBR (master boot record),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

In computer hardware, GUID Partition Table (GPT) is a standard for the layout of the partition table on a physical hard disk. It is a part of the Extensible Firmware Interface (EFI) standard proposed by Intel as a replacement for the PC BIOS, one of the few remaining parts of the original IBM PC. EFI uses GPT whereas BIOS uses a Master Boot Record (MBR).

Diagram illustrating the layout of the GUID Partition Table scheme. In this example, each logical block (LBA) is 512 bytes in size, and each partition entry is 128 bytes. LBA addresses that are negative indicate position from the end of the volume, with −1 being the last addressable block.
//

Features

Current PC BIOS schemes use a master boot record (MBR) to begin the process of initializing the disk. The MBR begins with an entry called the Master Boot Code, which contains an executable binary for the purpose of identifying and booting the active partition. EFI instead contains this capability itself, but to maintain backwards compatibility, GPT retains the MBR entry as the first sector on the disk followed by a Primary Partition Table Header, the actual beginning of GPT.

GPT uses modern logical block addressing (LBA) in place of the cylinder-head-sector (CHS) addressing used with MBR. Legacy MBR information is contained in LBA 0, the GPT header is in LBA 1, and the partition table itself follows. In 64-bit Windows operating systems, 16,384 bytes, or 32 sectors, are reserved for the GPT, leaving LBA 34 as the first usable sector on the disk.

According to Apple[1], "Do not assume that the {LBA} size is always going to be 512 bytes." When booting an Intel-based Mac from a hard drive that is partitioned, the hard disk must be partitioned according to GPT, rather than Apple Partition Map.

GPT also provides for redundancy. The GPT header and partition table are written at both the beginning and end of the disk.

Legacy MBR (LBA 0)

The primary purpose of the MBR at the beginning of the disk is to prevent MBR-based disk utilities from mis-recognizing, and possibly over-writing, GPT disks. A single partition, encompassing the entire GPT drive, is indicated. The System ID for the partition is set to 0xEE, indicating that it uses GPT. Because of this, EFI ignores the MBR. Some 32-bit OSes which cannot read GPT disks nevertheless recognize this ID and present the disk as an inaccessible GPT disk. Older OSes will generally recognize the disk as containing one partition of unknown type and no empty space, and then they'll typically also refuse to modify the disk unless the user explicitly requests and confirms the deletion of this partition. This way, accidental erasures are minimized.

If the disk is larger than two terabytes (the maximum partition size in the legacy MBR), the size of this partition is marked as 2 TiB, ignoring the rest of disk.

Partition table header (LBA 1)

The partition table header defines the blocks on the disk that can be utilized by the user (the usable blocks). It also defines the number and size of the partition entries that make up the partition table. On 64-bit Windows Server 2003 machines, there are 128 partition entries reserved, each 128 bytes long. Thus, 128 partitions can be created.

The header contains the disk GUID (Globally Unique Identifier). It records its own size and location (always LBA 1) and the size and location of the secondary GPT header and table (always the last sectors on the disk). Importantly, it also contains a CRC32 checksum for itself and for the partition table, which is verified by EFI processes on boot. Because EFI uses and verifies this checksum, hex editors should not be used to modify the contents of the GPT. Such modification would render the checksum invalid. In this case, EFI would overwrite the primary GPT with the secondary one, or, if both GPTs contained invalid checksums, would be unable to access the disk.

Partition table format
OffsetLengthContents
08 bytesSignature ("EFI PART", 45 46 49 20 50 41 52 54)
84 bytesRevision (For version 1.0, the value is 00 00 01 00)
124 bytesHeader size (in bytes, usually 5C 00 00 00 meaning 92 bytes)
164 bytes CRC32 of header (0 to header size), with this field zeroed during calculation
204 bytesreserved, must be zero
248 bytesCurrent LBA (location of this header copy)
328 bytesBackup LBA (location of the other header copy)
408 bytesFirst usable LBA for partitions (primary partition table last LBA + 1)
488 bytesLast usable LBA (secondary partition table first LBA - 1)
5616 bytesDisk GUID (also referred as UUID on UNIXes)
728 bytesPartition entries starting LBA (always 2 in primary copy)
804 bytesNumber of partition entries
844 bytesSize of a partition entry (usually 128)
884 bytesCRC32 of partition array
92*reserved, must be zeroes for the rest of the block (420 bytes for a 512-byte LBA)
LBA SizeTOTAL

The values for current and backup LBAs of the primary header should be the second sector of the disk (1) and the last sector of the disk, respectively. In the secondary header the same values are in reverse order.

Partition entries (LBA 2–33)

Partition entries are simple and straightforward. The first 16 bytes designate the partition type GUID. For example, the GUID for an EFI System partition is {C12A7328-F81F-11D2-BA4B-00A0C93EC93B}. The second 16 bytes contain a GUID unique to the partition. Starting and ending 64-bit LBAs are also recorded here, and space is allocated for partition names and attributes. There is no central registry for GUID partition type designators (needed), either de jure or de facto.

GUID partition entry format
OffsetLengthContents
016 bytesPartition type GUID
1616 bytesUnique partition GUID
328 bytesFirst LBA (little-endian)
408 bytesLast LBA (inclusive, usually odd)
488 bytesAttribute flags (e.g. bit 60 denotes read-only)
5672 bytesPartition name (36 UTF-16LE code units)
128TOTAL

According to Apple, "Do not hardwire the current size of the partition entry (128 bytes)." Microsoft TechNet says that attributes are divided into two half: lower 4 bytes represents partition independent attributes, whereas upper 4 bytes are partition type dependent. This seem odd, because Microsoft use the following bits in general[clarification needed]:

partition attributes
BitContent
0system partition (disk partitioning utilities must reserve the partition as is)
60read-only
62hidden
63do not automount (eg. do not assign drive letter)

Partition type GUIDs

Assoc. OSPartition typeGlobally-Unique Identifier (GUID)[1]
(None)Unused entry00000000-0000-0000-0000-000000000000
MBR partition scheme024DEE41-33E7-11D3-9D69-0008C781F39F
EFI System PartitionC12A7328-F81F-11D2-BA4B-00A0C93EC93B
BIOS Boot Partition21686148-6449-6E6F-744E-656564454649
WindowsMicrosoft Reserved PartitionE3C9E316-0B5C-4DB8-817D-F92DF00215AE
Basic Data Partition[2] EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
Logical Disk Manager metadata partition5808C8AA-7E8F-42E0-85D2-E1E90434CFB3
Logical Disk Manager data partitionAF9B60A0-1431-4F62-BC68-3311714A69AD
HP-UXData partition75894C1E-3AEB-11D3-B7C1-7B03A0000000
Service PartitionE2A1E728-32E3-11D6-A682-7B03A0000000
LinuxData partition[2] EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
RAID partitionA19D880F-05FC-4D3B-A006-743F0F84911E
Swap partition0657FD6D-A4AB-43C4-84E5-0933C84B4F4F
Logical Volume Manager (LVM) partitionE6D6D379-F507-44C2-A23C-238F2A3DF928
Reserved8DA63339-0007-60C0-C436-083AC8230908
FreeBSDBoot partition83BD6B9D-7F41-11DC-BE0B-001560B84F0F
Data partition516E7CB4-6ECF-11D6-8FF8-00022D09712B
Swap partition516E7CB5-6ECF-11D6-8FF8-00022D09712B
Unix File System (UFS) partition516E7CB6-6ECF-11D6-8FF8-00022D09712B
Vinum volume manager partition516E7CB8-6ECF-11D6-8FF8-00022D09712B
ZFS partition516E7CBA-6ECF-11D6-8FF8-00022D09712B
Mac OS X Hierarchical File System (HFS+) partition48465300-0000-11AA-AA11-00306543ECAC
Apple UFS 55465300-0000-11AA-AA11-00306543ECAC
ZFS[3] 6A898CC3-1DD2-11B2-99A6-080020736631
Apple RAID partition52414944-0000-11AA-AA11-00306543ECAC
Apple RAID partition, offline52414944-5F4F-11AA-AA11-00306543ECAC
Apple Boot partition426F6F74-0000-11AA-AA11-00306543ECAC
Apple Label4C616265-6C00-11AA-AA11-00306543ECAC
Apple TV Recovery partition5265636F-7665-11AA-AA11-00306543ECAC
SolarisBoot partition6A82CB45-1DD2-11B2-99A6-080020736631
Root partition6A85CF4D-1DD2-11B2-99A6-080020736631
Swap partition6A87C46F-1DD2-11B2-99A6-080020736631
Backup partition6A8B642B-1DD2-11B2-99A6-080020736631
/usr partition[3] 6A898CC3-1DD2-11B2-99A6-080020736631
/var partition6A8EF2E9-1DD2-11B2-99A6-080020736631
/home partition6A90BA39-1DD2-11B2-99A6-080020736631
EFI_ALTSCTR6A9283A5-1DD2-11B2-99A6-080020736631
Reserved partition6A945A3B-1DD2-11B2-99A6-080020736631
6A9630D1-1DD2-11B2-99A6-080020736631
6A980767-1DD2-11B2-99A6-080020736631
6A96237F-1DD2-11B2-99A6-080020736631
6A8D2AC7-1DD2-11B2-99A6-080020736631
NetBSD[4] Swap partition49F48D32-B10E-11DC-B99B-0019D1879648
FFS partition49F48D5A-B10E-11DC-B99B-0019D1879648
LFS partition49F48D82-B10E-11DC-B99B-0019D1879648
RAID partition49F48DAA-B10E-11DC-B99B-0019D1879648
concatenated partition2DB519C4-B10F-11DC-B99B-0019D1879648
encrypted partition2DB519EC-B10F-11DC-B99B-0019D1879648
  1. ^ The GUIDs in this table are written assuming a little-endian byte order. For example, the GUID for an EFI System partition is written as C12A7328-F81F-11D2-BA4B-00A0C93EC93B here, which corresponds to the 16 byte sequence 28 73 2A C1 1F F8 D2 11 BA 4B 00 A0 C9 3E C9 3B — only the first three blocks are byte-swapped.
  2. ab Linux and Windows use the same GUID for their respective data partitions.
  3. ab The GUID for /usr on Solaris is used as a generic GUID for ZFS by Mac OS X.
  4. ^ Definitions are in src/sys/sys/disklabel_gpt.h. NetBSD had used the FreeBSD GUIDs before unique NetBSD-specific GUIDs were created.

References

  1. ^ http://developer.apple.com/technotes/tn2006/tn2166.html

See also

  • Master boot record
  • GUID
  • EFI
  • Disk partitioning

External links

  • Microsoft TechNet: Disk Sectors on GPT Disks
  • Microsoft TechNet: Using GPT Drives on x86-64 Systems
  • Apple Developer Connection: Secrets of the GPT

最后

以上就是自觉夏天为你收集整理的GUID partition table (part of EFI) vs MBR (master boot record)的全部内容,希望文章能够帮你解决GUID partition table (part of EFI) vs MBR (master boot record)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(35)

评论列表共有 0 条评论

立即
投稿
返回
顶部