Is GPT aligned for 4k blocks?

4

1

The Wikipedia article for GUID Partition Table does not make it clear whether it is aligned to an underlying 4k-block filesystem. Seeing as the diagram shows the first block of the data sector as block 34, which is not divisible by 8 (512 bytes per sector * 8 sectors = a 4k block) then I am inclined to say no. Even if Windows makes the first partition a Microsoft Reserved Partition, as it apparently does usually, that partition is 65536 blocks (32 MiB), so still 65536+34=65570 which is not divisible by 8.

Am I missing something?

Ricket

Posted 2011-06-14T21:19:21.867

Reputation: 1 406

Answers

6

Yes, you're missing two things:

  • The EFI partition table is not required to be 34 blocks long. The Wikipedia article is downright misleading in this respect. Per the actual specification, rather than Wikipedia, the partition table length is determined by the size of the partition table entries and the number of partition table entries. They are both variable, and their values for any individial EFI partitioned disc are stored in the EFI partition table header. 34 blocks is merely what one gets with a 128 byte partition table entry size, a block size of 512 bytes, and a partition table with 128 entries. It's the minimum size of an EFI partition table, that the specification mandates. It's not the size.
  • The first usable block doesn't have to be the first used block. (It's not a "data section", by the way.) Just because on a particular disc block #34 may be the first usable block, it is not required that a partition start there. EFI partitioning tools can align partitions to whatever rules they like. (Indeed, several, such as Apple's Disk Utility, famously do. Rod Smith's gdisk has a non-trivial ruleset, too.) The EFI specification doesn't mandate that partitions be aligned to the first or last usable blocks. Indeed, it doesn't even, strictly speaking, mandate that the first usable block immediately follow the primary copy of the partition table.

JdeBP

Posted 2011-06-14T21:19:21.867

Reputation: 23 855

3

JdeBP's response is good, but I'd like to add that in practice, most modern partitioning tools align partitions on 2048-sector (1 MiB) boundaries by default, on both MBR and GPT disks. This keeps partitions aligned properly for Advanced Format drives as well as for other drive types, such as SSDs and some types of RAID arrays that have other alignment requirements. One partial exception to this rule is OS X's Disk Utility, which tends to create an EFI System Partition (ESP) as the first partition that begins on sector 40. Disk Utility creates subsequent partitions that begin on 1 MiB boundaries, though.

Rod Smith

Posted 2011-06-14T21:19:21.867

Reputation: 456