find_valid_gpt(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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 lore
  • ptes β€” 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:


⭐ 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