genimage icon indicating copy to clipboard operation
genimage copied to clipboard

Add runtime option to change GPT_ENTRIES

Open Apaczer opened this issue 6 months ago • 5 comments

normally could be done via sgdisk --resize-table=N [DEVICE], but here we need to patch image-hd.c

Apaczer avatar May 13 '25 16:05 Apaczer

You're talking about number_entries, the size of the gpt partition entry array, right?

What's the use-case for that?

michaelolbrich avatar May 25 '25 11:05 michaelolbrich

this is for sunxi device where's flashed u-boot conflicts with GPT location, so we use a workaround to move it outside 1MB (after) or fit inside 7KB. I've tried moving GPT after u-boot with gpt-location but later any partition's modification (e.g. resizing) make system unbootable propably overwriting LBA.

Apaczer avatar May 26 '25 21:05 Apaczer

Very strange. What tool do you use for the modification? I'm asking because we use the gpt-location to move the table behind the bootloader with other SoCs and resize and add partitions as well and I've never heard of a corrupted bootloader.

And have you tried it with a smaller table? I don't know how the corruption happens in your case, but the only thing I can think of is, that the tool moves the table to the default location. However, if it does that, the I would expect that is does not respect the reduced size either and increases the size back to 128 entries.

michaelolbrich avatar May 27 '25 06:05 michaelolbrich

What tool do you use for the modification?

Mostly I'm trying to expand last partition to make use of the remaining space and I've tried parted to modify endpoint then other tools to resize (depends on FSTYPE). The gparted from my PC machine shows first 1MB sector as unallocated space, so I believe libparted fails to recognize relocated main GPT correctly (other than default). I admit I've tested now with gdisk instead to modify partitions and it doesn't have this problem, so it was my fault sticking to parted.

And have you tried it with a smaller table?

You mean reduces entries? Yes, with smaller value (with/without adjusting main partition table via gpt-location) the parted doesn't corrupts bootloader, so it might be still worth adding this functionality to make image more compatible/safe.

Apaczer avatar May 27 '25 19:05 Apaczer

FYI: https://lists.gnu.org/archive/html/bug-parted/2024-01/msg00000

Apaczer avatar Jun 07 '25 13:06 Apaczer