Subject: bug#19137: mklabel gpt created invalid Protective MBR

From: "Ulrich Windl" <[email-masked]>
Date: Fri, 21 Nov 2014 08:50:24 +0100

GNU Parted 2.3 creates an invalid Protective MBR (for a 3MB test image):
--
hexdump -C gptgood
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001c0  01 00 ee fe ff ff 01 00  00 00 ff 17 00 00 00 00  |................|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
[...]
---

Partition #1 (or is it #4?) decodes as this:
--
Legacy MBR:
    MBR Signature     = aa55
    Unique Signature  = 00000000

    Partition 1:
        Boot Indicator    : non-bootable
        Starting Cylinder =          0
        Starting Head     =          1
        Starting Sector   =          0
        System ID         =       0xee
        Ending Cylinder   =       1023
        Ending Head       =         63
        Ending Sector     =        254
        Relative Sectors  =          1
        Total Sectors     =       6143
--
First, UEFI says the StartingCHS should be set to 0x000200, that should be 0/0/2, not 0/1/0. Second, UEFI says Ending CHS should be set to the CHS address of the last logical block on the disk, _or_ 0xffffff if it's not possible to represent the value in the field. For my 3MB image that value is not correct.