GPT:Primary header thinks Alt. header is not at the end of the disk

We’re getting GPT errors during boot process, what is wrong here?

Error is:

machine:/home/user# dmesg | grep -i gpt
Command line: BOOT_IMAGE=(hd0,gpt2)/boot/bzImage root=/dev/mmcblk0p2 rootwait
Kernel command line: BOOT_IMAGE=(hd0,gpt2)/boot/bzImage root=/dev/mmcblk0p2 rootwait
GPT:Primary header thinks Alt. header is not at the end of the disk.
GPT:61046783 != 61071359
GPT:Alternate GPT header not at the end of the disk.
GPT:61046783 != 61071359
GPT: Use GNU Parted to correct GPT errors.

Disk is:

Disk /dev/mmcblk0: 29 GB, 31268536320 bytes, 61071360 sectors
3786 cylinders, 256 heads, 63 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Device       Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/mmcblk0p1    0,0,2       1023,255,63          1   61046783   61046783 29.1G ee EFI GPT

Variables are:

MENDER_STORAGE_TOTAL_SIZE_MB_DEFAULT = "29820"
MENDER_STORAGE_DEVICE = "/dev/mmcblk0"
MENDER_STORAGE_TOTAL_SIZE_MB = "29820"
MENDER_BOOT_PART_SIZE_MB = "128"
MENDER_DATA_PART_SIZE_MB = "1024"

try using sgdisk -e
this should fix the GPT disk image before you image it to your target disk

try using sgdisk -e
this should fix the GPT disk image before you image it to your target disk

This is only true if the “offline” image is the exact same size as the storage medium size.

GPT alternative headers are relative to the storage medium size, e.g they are at block position -1.

So you need to run sgdisk -e or echo 'w' | fdisk /dev/mmcblk0 or similar on your device once to make sure the alternative GPT headers are written to the correct location.