[PATCH 6/6] partitions: gpt: refresh partition tables when necessary

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Dec 15 06:15:13 PST 2025



On 12/15/25 3:13 PM, Sascha Hauer wrote:
> On Mon, Dec 15, 2025 at 01:47:09PM +0100, Ahmad Fatoum wrote:
>> 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 at pengutronix.de>
>>
>> With below point addressed:
>>
>> Reviewed-by: Ahmad Fatoum <a.fatoum at 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.
> 
> We can know that this feature is compiled in, but we don't know yet if it
> is actually enabled, so the best we can write is something like:
> 
> 	dev_info(dev, "GPT: will repair later when global.system.gpt_refresh is true\n");

Maybe: "GPT: will repair later if global.system.gpt_refresh=1" ?

> 
> I added this while applying.
> 
> Sascha
> 

-- 
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 |




More information about the barebox mailing list