Skip to content

gpt: skip unused partition entries instead of stopping at the first one - #840

Open
robbinjanssen wants to merge 1 commit into
bkerler:masterfrom
robbinjanssen:fix/gpt-unused-entries
Open

robbinjanssen wants to merge 1 commit into
bkerler:masterfrom
robbinjanssen:fix/gpt-unused-entries

Conversation

@robbinjanssen

@robbinjanssen robbinjanssen commented Nov 14, 2026 •

Copy link
Copy Markdown

Problem

gpt.parse() stops at the first partition entry whose unique GUID is all zeros (break). The UEFI spec allows used entries after unused ones, for example after some partitions were deleted, so every partition after such a gap is missing: printgpt does not list it, and commands that look a partition up by name (r, w, e, …) cannot find it.

Where it showed up

A Lenovo ThinkSmart View (APQ8053/MSM8953) after the repartitioning commonly used to install Linux on it (rickx/ubuntu-thinksmart's ubuntu_layout.sfdisk): entries 25 and 26 are empty and persist is entry 27, at the end of the eMMC.

  • Before: printgpt lists 24 partitions, ending with system; persist is not there.
  • After: 25 partitions, persist at sector 15204319 with 65536 sectors (what sfdisk -l shows on the device).
  • The stock GPT of the same device (51 contiguous entries) parses exactly as before.

Change

break → continue. entryoffset is already computed from the entry index, so later entries keep their correct offsets.

Testing

Parsed the primary GPT of both layouts with gpt().parse(data, 512): the stock one (51 partitions, unchanged) and one created by sfdisk from that layout on an image file of the same size (persist found only with the fix). On the device itself, printgpt after repartitioning did not list persist (that is how this was found); the fix is tested on the parser with that layout, not yet against the device.

🤖 Generated with Claude Code

The GPT parser stopped at the first entry with an all-zero unique GUID.
The UEFI spec allows used entries after unused ones (a partition table
where some partitions were deleted), so every partition after such a gap
was missing from printgpt and from the commands that look a partition up
by name.

Seen on a Lenovo ThinkSmart View (MSM8953) after the common Linux
repartitioning: entries 25 and 26 are empty and persist is entry 27,
so printgpt listed 24 of 25 partitions and persist could not be found.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
m0s4ik pushed a commit to m0s4ik/thinksmart-view-debian that referenced this pull request Nov 14, 2026
…DL tips

- hardware.md: a unit with the FocalTech FT8201 panel runs the v0.4 image
  unchanged (lk2nd patches the DT, the kernel has the panel driver): what
  was checked, the multi-touch input device, warnings seen in the kernel
  log, and what was not tested (touch after blanking). install.md,
  kernel.md and README follow.
- flashing.md: the repartitioning removes p25-p51 and creates a new, empty
  persist at the end of the eMMC; how to copy the original persist from
  the backup, by sector because edl does not see p27 (bkerler/edl#840).
- flashing.md: adb reboot edl; EDL mode times out when idle; a resumable
  backup in parts with edl rs when edl rf stops halfway.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant