|
The Road to GPTApple's previous disk partitioning scheme, known as Apple partition map (APM), was introduced with the Macintosh II in 1987. The scheme was very well designed, and it has survived, with very few changes, for almost twenty years. However, in recent years APM's limitations have been looming on the horizon. Specifically, APM is restricted to 32-bits worth of blocks. With a standard block size of 512 bytes, this translates to a maximum disk size of 2 TB. With the rate that hard disks are growing, it's easy to imagine a typical desktop computer shipping with more than 2 TB of storage in the next few years. Apple did consider extending APM to support larger disks. However, as such a change would break all existing partitioning tools, it was just as convenient to switch to an entirely new partitioning scheme. After some serious thought, Apple decided to adopt GPT. The GUID partition table (GPT) partitioning scheme was introduced by Intel as part of an effort to introduce more modern firmware to generic PC hardware. Traditional PC hardware uses BIOS firmware, which uses a partitioning scheme known as master boot record (MBR). MBR has lots of severe limitations, and is not appropriate for a modern computer. Intel's modern firmware, known as the Extensible Firmware Interface (EFI), includes a new partitioning scheme, GPT. One of the nice features about GPT is that it is defined by a formal standard. Specifically, GPT is defined by the following documents:
Because GPT is defined by a formal specification, it is not necessary to describe it in detail here. Thus, this technote concentrates on how GPT is used by Apple. It starts with a high-level overview of GPT. It then describes how Apple has rolled out support for GPT, including a discussion of our partitioning policies. Finally, it concludes with some hints and tips for working with GPT on the Macintosh. GPT OverviewGPT is a simple but effective partitioning scheme. Table 1 shows a high-level summary of the block layout used by GPT. In this table, n is the number of blocks on the disk, and b is the number of blocks used to describe the partition entry array (typically 32, but see below for a discussion of this). Table 1: GPT Summary
The protective MBR is an MBR that defines a single partition entry that covers the entire area of the disk used by GPT structures and partitions. It is designed to prevent GPT-unaware programs from accidentally modifying a GPT disk. A GPT-unaware program sees the GPT disk as an MBR disk with a single, unknown partition. In a way, this is like the HFS wrapper around an HFS Plus disk. WARNING: See Protective MBR for an important discussion of the protective MBR. The partition table header is a structure that defines various aspects of the disk, including a GUID to uniquely identify the disk, the starting block of the partition entry array, and the size of each partition entry in that array. The partition entry array is an array of partition entries, each of which defines a partition (or is all zero, indicating that the entry is not in use). The array is stored in a contiguous range of blocks on disk, which is treated as an array of bytes. The first partition entry start at the first byte of the array, the next partition entry follows immediately after that, and so on. The size of these entries is given by a field in the partition table header. Each partition entry contains a GUID to uniquely identify the partition itself, a GUID to identify the partition type, the start and end block of the partition, and the partition name. For more details about these structures, read the GPT specification. As you're reading, please keep in mind the following:
Apple's Support for GPTAny Macintosh computer running Mac OS X 10.4 and later can mount GPT-partitioned disks. Intel-based Macintosh computers can boot from GPT. By default, the internal hard disk is formatted as GPT. IMPORTANT: While Intel-based Macintosh computers can boot from GPT and APM, Apple only supports booting Mac OS X on these machines from GPT. Apple's GUI tools, like the Installer, will prevent you installing Mac OS X for an Intel-based Mac on non-GPT disks. On all Intel-based Macintosh computers (and, starting with Mac OS X 10.4.6, PowerPC-based computers as well), Disk Utility has full support for GPT. The Note: If you're using a PowerPC-based computer running Mac OS X 10.4.6, you'll be disappointed to discover that the Advice for PartitionersThe GPT specification is very flexible; the standard does not define exactly how to partition a disk, it merely describes the realm of what's possible. When Apple implemented our support for GPT, we made a number of policy decisions on how to lay out the disk, and we recommend that third party disk utilities for the Macintosh follow our policies. GPT Partition TypesMost GPT partition types are defined in the GPT specification. Beyond that, Apple has defined a number of GUIDs to denote Apple-specific partition types. These are described in Table 2. Table 2: Apple-defined GPT partition types
Partitioning PolicyWhen partitioning a disk as GPT, we lay out the partition map differently depending on whether the disk is tiny, small or big. For the sake of this discussion, a tiny disk is one whose size is less than 1 GB, a small disk is between 1 GB and 2 GB in size, and a big disk is one whose size is 2 GB or more. Apple's partitioning policy is as follows:
Table 3 is a summary of the policy for each disk type. Table 3: Partitioning policy by disk type
IMPORTANT: We align partitions to 4 KB to accommodate limitations of the HFS Plus file system implementation on Mac OS X (r. 4259751). Note: We leave free space after each partition to make it easier for future system software to manipulate the partition map in ways that we can't anticipate currently. ESP ExplainedThe EFI system partition (ESP) is a special partition from which EFI can load EFI (boot-time) device drivers. The EFI firmware in Macintosh computers fully supports the ESP, although Apple does not currently use it for anything. We create the ESP on big disks to make things easier if we ever need to use ESP-based drivers. We strongly recommend that you do the same. When you initialise the ESP, keep in mind that it must conform to the specification in the EFI documentation. While the ESP looks like a FAT32 volume, it is actually an EFI file system which "will be maintained by specification and will not evolve over time to deal with errata or variant interpretations in OS file system drivers". For more details, see Section 12.2 "File System Format" of the UEFI Specification, version 2.0. Thus, you should not use the newfs_msdos utility to create the ESP because there is no way to guarantee that it will create an EFI file system. You might consider including a (compressed) disk image of the ESP within your disk utility. Hints and TipsThis section describes a number of helpful hints when dealing with GPT. GPT Command Line ToolsSince Mac OS X 10.4, Apple has included a command line tool, Systems that fully support GPT include a version of the Be aware that these two tools are based on different source bases. The IMPORTANT: Because of its heritage, the One nice feature of the Copying ConcernsBe careful when doing a block-for-block copy of a GPT disk. The GUID in the partition table header that identifies the disk (and the GUIDs in each partition entry) are meant to be globally unique, and Apple's system software relies on this feature. If you block copy a disk, you should consider whether it's appropriate to set these GUIDs to new values. For example:
If you don't follow this advice, you may encounter weird problems. For example, if you duplicate a disk without updating the GUIDs, the computer might boot from either the original or the copy in an unpredictable fashion (perhaps toggling from boot to boot). The Last BlockThere are a number of third party disk drives that, due to buggy firmware, report an error if you access the last block on the disk. This was not a serious problem for APM. It's easy to create an APM that avoids the last block by creating a small For GPT, however, this problem is much more serious. The GPT specification requires that the last block of the disk contain the backup partition table header; you can't just choose to avoid it! Apple handles this problem by ignoring any error when reading the backup partition table header in the last block of a GPT disk. If such an error occurs, the disk has a valid primary partition table and an invalid backup. According to the rules laid out by the GPT specification, such a disk is still considered to be a valid GPT disk. On the other hand, when partitioning a disk as GPT, if writing to the last block results in an error, the partitioning operation will fail. Such a disk can't be partitioned as a GPT disk using Apple software. Protective MBRBy definition, all GPT disks start with a protective MBR. This is an MBR that defines a single partition entry (of type 0xEE) that covers the entire area of the disk used by GPT structures and partitions. It is designed to prevent GPT-unaware programs from accidentally modifying a GPT disk. A GPT-aware program can recognise that a disk contains a GPT by checking block 1 and the last block, as discussed in the EFI specification. In addition, it should check that block 0 contains a protective MBR. If block 0 contains any other form of MBR, it should refuse to manipulate the disk. Specifically, if block 0 contains an MBR with more than one partition entry, or a single partition entry whose WARNING: Failure to comply with this recommendation may result in the loss of user data. Further Reading
Document Revision History
Posted: 2006-11-06 |
|