Mender-Convert UEFI GPT Output Image


First I would like to say thanks for all the work on mender-convert (and obviously mender itself), it is a great product.

I am attempting to create a Debian image for generic x86 hardware with UEFI and no legacy boot support. When I run the mender-convert on a disk partitioned with GPT, it always outputs an image in MBR/msdos format. I do see a comment in the mender-convert-package script that says:

# Create partition table. TODO: GPT support

Does that mean the tool will never output a GPT/UEFI img.gz file? I’m confused because the first time I ran the tool I used an msdos/MBR image for input and I could swear it created a GPT/UEFI image. I remember because the image didn’t boot at first when I wrote it back to the same device, I had to change the PC to UEFI instead of BIOS before it would boot.

Is there something I can change to get a GPT/UEFI output image? Some of the devices I’m trying to use are only UEFI and won’t boot legacy.

Just for reference, here is the input image partitions:

Disklabel type: gpt
Disk identifier: 9E3F1724-97A6-45D2-B640-361293210FA9

Device    Start      End  Sectors  Size Type
1          2048  1050623  1048576  512M EFI System
2       1050624 12769279 11718656  5.6G Linux filesystem

And here is the output image partitions:

Disklabel type: dos
Disk identifier: 0x271b6a9f

Device  Boot    Start      End  Sectors  Size Id Type
1       *       16384  1064959  1048576  512M  c W95 FAT32 (LBA)
2             1064960 17154047 16089088  7.7G 83 Linux
3            17154048 33243135 16089088  7.7G 83 Linux
4            33243136 33505279   262144  128M 83 Linux

Also, while mender-convert is running I see in work/convert.log that it does create an EFI boot partition with EFI files in the mender-convert-modify section. I’m wondering if the Mender Artifact contains an EFI image that I could extract and use?


Hi @bakern, thank you for kind words about Mender and welcome to the community.

So the the directory structure that is created is compatible with UEFI but as you have noticed the output image is not an GPT image and this has been the case so far.

As you have noticed the TODO, this is something that we need to add.

The changes needed to create an GPT image are probably in these lines, and should not be much.

Yes, GPT should be the default, as this is what is specified in the UEFI standard. However, be aware that despite what the standard says, GPT is not always supported. In particular, the Beaglebone Black only boots if the partition table is msdos/MBR style. Maybe a good idea is to make the defaults x86 -> GPT, ARM -> MBR? With options to override either?

Makes sense. Actually found a task for this, I think it was referring the old version of mender-convert but can re-purpose this one I guess as it is still valid.

I verified by changing the lines

run_and_log_cmd "${PARTED} -s ${img_path} mklabel msdos"
run_and_log_cmd "${PARTED} -s ${img_path} unit s mkpart primary fat32 ${boot_part_start} ${boot_part_end}"


run_and_log_cmd "${PARTED} -s ${img_path} mklabel gpt"
run_and_log_cmd "${PARTED} -s ${img_path} unit s mkpart ESP fat32 ${boot_part_start} ${boot_part_end}"

It seems to work fine. Just another idea, how about just use whichever type of partition table the source image is using? For example I just moved it into an if/else block checking the source image partition scheme and it seemed to work:

MENDER_PARTITION_TYPE=$(disk_get_part_value ${disk_image} 1 SCHEME)
if [ "${MENDER_PARTITION_TYPE}" == "gpt" ]; then

Thanks for looking in to this. Looks simple enough :slight_smile: .

I like the conditional approach based on input disk type,

MENDER_PARTITION_TYPE=$(disk_get_part_value ${disk_image} 1 SCHEME)
if [ "${MENDER_PARTITION_TYPE}" == "gpt" ]; then

Would you be able to create a pull-request for this?

I created a pull request:

If someone could review it and let me know if any changes need to be made, that would be great.