[parted-devel] Offset GPT partition entries

Elliott, Robert (Server Storage) Elliott at hp.com
Wed Apr 3 22:54:29 UTC 2013


You're trying to lay out the disk as:
LBA 0		protective or hybrid MBR (required to be here)
LBA 1		GPT Header (required to be here)
LBA 2		restricted for some other purpose
LBA 3..m-1 	GPT Partition Entry Array   (size m-3)
LBA m		First Usable LBA
...
LBA n-(m-3)-2	Last Usable LBA
LBA n-(m-3)-1..n-1 	GPT Partition Entry Array  (size m-3)
LBA n			Alternate GPT Header (required to be here)

LBAs 0, 1, and n have fixed content; the other content can float.

The UEFI GPT specification allows for gaps between:
- the GPT Header and the GPT Partition Entry Array
- the GPT Partition Entry Array and the First Usable LBA
- the Last Usable LBA and the alternate GPT Partition Entry Array
- the alternate GPT Partition Entry Array and the alternate GPT Header
but doesn't remember the gaps used by one GPT in the other GPT.

If the primary GPT Header goes bad and the primary GPT is rewritten 
by copying the alternate GPT Header and alternate GPT Partition 
Entry Array back into the primary location, how would software know that it is
not supposed to place the Partition Entry Array at LBA 2?  The software doing
this may or may not understand the special case.

There is no rule in the UEFI GPT specification that there be the same spacing
between the alternate GPT Header and the alternate GPT Partition Entry Array
and the alternate Header as there is between the primary GPT Header and the
primary GPT Partition Entry Array, but that might be a way to communicate
this need. We could try to add such a rule if that's the only viable solution.

> +++ b/libparted/labels/gpt.c
>    last_usable_if_grown
> -    = (disk->dev->length - 2 -
> +    = (disk->dev->length - gpt->PartitionEntryLBA -
>        ((PedSector) (PED_LE32_TO_CPU (gpt->NumberOfPartitionEntries)) *
>         (PedSector) (PED_LE32_TO_CPU (gpt->SizeOfPartitionEntry)) /
>         disk->dev->sector_size));

Does this leave room for the alternate GPT (Header and Partition Entry
Array)?  It seems to be missing a "2 *" factor.

---
Rob Elliott    HP Server Storage



> -----Original Message-----
> From: parted-devel-bounces+elliott=hp.com at lists.alioth.debian.org
> [mailto:parted-devel-bounces+elliott=hp.com at lists.alioth.debian.org] On
> Behalf Of Derek Foreman
> Sent: Wednesday, 03 April, 2013 2:44 PM
> To: parted-devel at lists.alioth.debian.org
> Subject: [parted-devel] Offset GPT partition entries
> 
> Hello,
> 
> I'm working with some hardware that boots off an sdcard and required
> U-Boot be at LBA 2.
> 
> I'd like to use GPT partitioning on the sdcard, but by default GPT
> stores partition entries at LBA 2.
> 
> I've attached my first draft patch that adds an optional extra parameter
> to mklabel to allow creating a GPT with a different offset.  Any
> feedback would be great.
> 
> Thanks,
> Derek



More information about the parted-devel mailing list