Skip to content

Commit

Permalink
partitions/efi: do not require gpt partition to begin at sector 1
Browse files Browse the repository at this point in the history
When detecting a valid protective MBR, the Linux kernel isn't picky about
the partition (1-4) the 0xEE is at, but, unlike other operating systems,
it does require it to begin at the second sector (sector 1).  This check,
apart from it not being enforced by UEFI, and causing Linux to potentially
fail to detect any *valid* partitions on the disk, can present problems
when dealing with hybrid MBRs[1].

For compatibility reasons, if the first partition is hybridized, the 0xEE
partition must be small enough to ensure that it only protects the GPT
data structures - as opposed to the the whole disk in a protective MBR.
This problem is very well described by Rod Smith[1]: where MBR-only
partitioning programs (such as older versions of fdisk) can see some of
the disk space as unallocated, thus loosing the purpose of the 0xEE
partition's protection of GPT data structures.

By dropping this check, this patch enables Linux to be more flexible when
probing for GPT disklabels.

[1] http://www.rodsbooks.com/gdisk/hybrid.html#reactions

Signed-off-by: Davidlohr Bueso <davidlohr@hp.com>
Reviewed-by: Karel Zak <kzak@redhat.com>
Acked-by: Matt Fleming <matt.fleming@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Davidlohr Bueso authored and torvalds committed Sep 11, 2013
1 parent 33afd7a commit 3e69ac3
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions block/partitions/efi.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ static inline int pmbr_part_valid(gpt_mbr_record *part)
if (le32_to_cpu(part->starting_lba) != GPT_PRIMARY_PARTITION_TABLE_LBA)
goto invalid;

if (le32_to_cpu(part->start_sector) != 1UL)
goto invalid;

return 1;
invalid:
return 0;
Expand Down

0 comments on commit 3e69ac3

Please sign in to comment.