From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
BAREBOX <barebox@lists.infradead.org>
Subject: Re: [PATCH 6/6] partitions: gpt: refresh partition tables when necessary
Date: Mon, 15 Dec 2025 13:47:09 +0100 [thread overview]
Message-ID: <3ad1186d-9e8c-4276-8f42-aef60de4956b@pengutronix.de> (raw)
In-Reply-To: <20251203-efi-partition-refresh-v1-6-f0b6e79b5fa0@pengutronix.de>
Hi,
On 12/3/25 4:19 PM, Sascha Hauer wrote:
> The GPT alternative header must be at the end of the device. When disk
> images are written to a device this often is not the case which results
> in warnings:
>
> WARNING: mmc0: GPT:Primary header thinks Alt. header is not at the end of the disk.
> WARNING: mmc0: GPT:6561831 != 62160895
> WARNING: mmc0: GPT:Alternate GPT header not at the end of the disk.
> WARNING: mmc0: GPT:6561831 != 62160895
> WARNING: mmc0: GPT: Use parted to correct GPT errors.
>
> This patch adds support for automatically rewriting the partition table
> when this happens. This behaviour is optional and needs to be enabled at
> compile time with CONFIG_PARTITION_DISK_EFI_REFRESH. Also this is
> runtime configurable with global.system.gpt_refresh
>
> Link: https://lore.barebox.org/20251128111929.2463263-1-s.hauer@pengutronix.de
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
With below point addressed:
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> - if (error_found)
> + if (error_found) {
> + add_gpt_refresh(blk);
> dev_warn(dev, "GPT: Use parted to correct GPT errors.\n");
With CONFIG_PARTITION_DISK_EFI_REFRESH enabled, I would suggest changing
this to a dev_info(dev, "GPT: barebox will autocorrect.\n") or something.
> + }
> +
> return;
> }
>
> @@ -424,7 +519,7 @@ static int find_valid_gpt(struct efi_partition_desc *epd, void *buf)
> goto fail;
>
> if (IS_ENABLED(CONFIG_PARTITION_DISK_EFI_GPT_COMPARE))
> - compare_gpts(blk->dev, pgpt, agpt, lastlba);
> + compare_gpts(blk, pgpt, agpt, lastlba);
>
> epd->good_pgpt = good_pgpt;
> epd->good_agpt = good_agpt;
> @@ -874,8 +969,16 @@ static struct partition_parser efi_partition_parser = {
> .name = "gpt",
> };
>
> +#ifdef CONFIG_PARTITION_DISK_EFI_REFRESH
> +BAREBOX_MAGICVAR(global.system.gpt_refresh, "When true, refresh GPT partitions when necessary");
> +#endif
> +
> static int efi_partition_init(void)
> {
> + if (IS_ENABLED(CONFIG_PARTITION_DISK_EFI_REFRESH))
> + globalvar_add_simple_bool("system.gpt_refresh",
> + &global_gpt_refresh);
> +
> return partition_parser_register(&efi_partition_parser);
> }
> postconsole_initcall(efi_partition_init);
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2025-12-15 12:47 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-03 15:19 [PATCH 0/6] partitions: GPT: " Sascha Hauer
2025-12-03 15:19 ` [PATCH 1/6] partitions: gpt: pass epd context pointer to find_valid_gpt() Sascha Hauer
2025-12-15 12:28 ` Ahmad Fatoum
2025-12-03 15:19 ` [PATCH 2/6] partitions: gpt: only write actual ptes size to device Sascha Hauer
2025-12-15 12:29 ` Ahmad Fatoum
2025-12-03 15:19 ` [PATCH 3/6] partitions: gpt: factor out a function to write primary/alternate GPT Sascha Hauer
2025-12-15 12:34 ` Ahmad Fatoum
2025-12-03 15:19 ` [PATCH 4/6] partitions: gpt: write inactive GPT first Sascha Hauer
2025-12-15 12:38 ` Ahmad Fatoum
2025-12-03 15:19 ` [PATCH 5/6] partitions: gpt: fix GPT restauration from alternate GPT Sascha Hauer
2025-12-15 12:41 ` Ahmad Fatoum
2025-12-03 15:19 ` [PATCH 6/6] partitions: gpt: refresh partition tables when necessary Sascha Hauer
2025-12-15 12:47 ` Ahmad Fatoum [this message]
2025-12-15 14:13 ` Sascha Hauer
2025-12-15 14:15 ` Ahmad Fatoum
2025-12-15 14:09 ` [PATCH 0/6] partitions: GPT: " Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3ad1186d-9e8c-4276-8f42-aef60de4956b@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox