find_valid_gpt(9)
π find_valid_gpt(9) π
okay so bestie, welcome to the kernel API manual page for find_valid_gpt β yes it's a section 9 function, yes it's iconic, and yes we're gonna get through it together π«Ά
β¨ NAME β¨
find_valid_gpt β literally searches the disk for valid GPT headers and PTEs ππ
πΈ SYNOPSIS πΈ
int find_valid_gpt (struct parsed_partitions *state , gpt_header **gpt ,
gpt_entry **ptes );
like that's the whole signature, no cap. three args, one int coming back at you π
π ARGUMENTS π
stateβ the disk parsed partitions, i.e. the whole situation we're working with, bestie ποΈgptβ GPT header ptr, filled on return β¨ so you hand it over empty and it comes back with loreptesβ PTEs ptr, also filled on return π¦ same energy, different pointer
π DESCRIPTION π
so the way this works is: it returns 1 if valid, 0 on error. periodt π
If it is valid, it returns pointers to newly allocated GPT header and PTEs β like, freshly allocated, brand new, main character memory π
Validity depends on the PMBR being valid (or being overridden by the GPT header and PTEs valid, or the Alternate GPT header and PTEs valid). iykyk, it's a whole little validity stack π§
β οΈ okay important one: if the Primary GPT header is not valid, the Alternate GPT header is not checked unless the 'gpt' kernel command line option is passed. not me being strict about it but fr fr that's the rule π
And why, you ask? Because this protects against devices which misreport their size β shady little devices lying about how big they are π β and it forces the user to decide to use the Alternate GPT. your call, bestie, the kernel isn't gonna make it for you π
π SEE ALSO π
go stan the rest of the family, they all ate:
- Kernel file
./block/partitions/efi.c efi_crc32(9)last_lba(9)is_pmbr_valid(9)read_lba(9)alloc_read_gpt_entries(9)alloc_read_gpt_header(9)is_gpt_valid(9)is_pte_valid(9)compare_gpts(9)utf16_le_to_7bit(9)efi_partition(9)
β and that's the page!! sourced straight from ./block/partitions, dated October 2026, filed under find_valid_gpt(9) β slay, go read your partition tables responsibly πππ¦
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms