[PATCH 1/6] partitions: gpt: Adjust last_usable_lba to real device size when writing
Sascha Hauer <[email protected]> Wed, 01 Jul 2026 11:27:34 +0200
| Newsgroups | org.infradead.lists.barebox |
|---|---|
| Message-ID | <[email protected]> |
When writing disk images to a device the last_usable_lba field in the GPT header normally doesn't match the actual device size. Adjust the field to the actual device size when writing a partition table. Signed-off-by: Sascha Hauer <[email protected]> --- common/partitions/efi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/partitions/efi.c b/common/partitions/efi.c index 674f920743..28198f25b1 100644 --- a/common/partitions/efi.c +++ b/common/partitions/efi.c @@ -862,6 +862,8 @@ static int __efi_partition_write(struct efi_partition_desc *epd, bool primary) size = count / GPT_BLOCK_SIZE; + gpt->last_usable_lba = cpu_to_le64(last_lba(blk) - (size + 2)); + if (primary) { my_lba = 1; -- 2.47.3