EFI System Partitions

UP board

Intel® Atom™ x5-z8350
UEFI BIOS

I’ve been working with these boards on a project and am finally able to have a look in to full mender integration with the dual FS updates. We have a build system producing images for the boards using debootstrap that works well for us, it’s not quite the same as taking a golden base image and converting it to the mender format, it was reverse engineered from one though.

I’ve been having a poke around in mender-convert and it looks as though the partition structure that works with out boards isn’t supported by the script yet. We have the following structure:

Partition Number Type File System Format Mount Point
1 EFI System fat32 /boot/efi
2 Linux filesystem ext4 /boot
3 Linux filesystem ext4 /

Running mender-convert at first just gives Unfortunately we where not able to find the Linux kernel image. This is because the script is expecting the /boot partition to be at partition 1, not the EFI one. I’m not entirely sure whether EFI is supported or not. I’ve found the MENDER_GRUB_EFI_INTEGRATION flag but also, at line 236 of mender-convert-modify a comment saying this won’t work with EFI. I suspect this may be an outdated comment, it comes from the rewrite of the file 2 years ago. Plus I’ve found some more stuff in the grub-mender-grubenv README.md file about this sort of partition layout explicitly.

I’ve started playing with adding some probing of the input image to see if there is an EFI partition with a view to replicating the partition layout in the final image. I’m about half way although I’m getting a bit worried that there’s too much conditional checking getting added in.

Has anyone built any images with an EFI System partition for ubuntu?
What did you use to build them
How much more beyond creating and installing 2 rootfs partitions and installing / configuring grub-mender-grubenv is there to preparing a mender compatible image with the dual root fs setup?
Are there any guides on how this is done?

Here’s my fork of the repo that is the first baby steps to having something working: git@github.com:stevenleadbeater/mender-convert.git

I’m struggling a bit with the package script. I guess I’ll just have to bite the bullet on that one and integrate with it if I want this to work. Previously I’ve mounted an .img file as a loop device and partition it, mount it and do the disk image that way in a chroot. All this offset tracking stuff seems intimidating and easy to mess up

I guess my last question is, if I hack my way through this and get it working, assuming everything else still works, are you guys even going to want this going in or not?

1 Like

I feel pretty sheepish now, it looks as though it was in fact having the kernel in a separate partition that was causing the problem not the System EFI partition. I re-rolled our image with a combined kernel + rootfs partition and mender-convert ran stock for me without upset

1 Like

He @steve84 !

It seems you’ve solved the issue.

Could you describe more specifically steps that you took to install Mender on system with EFI?

Hi @andrewtimoshenko mender-convert works out of the box following the guides. I got the wrong end of the stick when I was reading the output because I had a 3 partition layout on my images,

partition 1 was /boot,
partition 2 was /boot/efi,
partition 3 was /

when I collapsed the second partition so I only had:

partition 1 as /boot,
partition 2 as /

Everything worked as expected

1 Like

Do you mean you just removed /boot/efi from partition table? Now where /boot partition ends then rootfs partition immediately starts?

Not exactly, I rebuilt the image from scratch with 2 partitions only, /boot ending where / begins using debootstrap. If I just removed the EFI partition from the existing image it would break it and stop it booting.

Hi @steve84, I would very appreciate if you could describe here how you used debootstrap for collapsing /boot/efi partition.

I’m using the following sort of thing in bash, the middle bit is the only difference really. I install stuff in to the chroot as part of a CI / CD process

set -e

#setup file system
CHROOT=/var/chroot/bionic
sudo mkdir -p $CHROOT

# make a blank .img of the desired size
truncate --size 4G mender-image.img

# Create partition layout in the blank image
sgdisk --clear \
  --new 1::+44M --typecode=1:ef00 --change-name=1:'EFI System' \
  --new 2::-0 --typecode=2:8300 --change-name=2:'Linux root filesystem' \
  mender-image.img -g

#Create a loop device based on the partitioned image
sudo losetup -P /dev/loop99 mender-image.img $CHROOT

#Format the partitions in the image
sudo mkfs.fat -F32 /dev/loop99p1
sudo mkfs.ext4 -F -L "rootfs" /dev/loop99p2

# mount the formatted partitions in the image
sudo mount -o rw /dev/loop99p2 $CHROOT
sudo mkdir -p $CHROOT/boot/efi
sudo mount -o rw /dev/loop99p1 $CHROOT/boot/efi

# Run debootstrap against the mounted file system
sudo debootstrap --arch=amd64 --include systemd bionic $CHROOT http://archive.ubuntu.com/ubuntu/

#Mount enough of your host system in to the image to allow you to run apt commands
sudo mount --bind /dev $CHROOT/dev/
sudo mount --bind /sys $CHROOT/sys/
sudo mount --bind /proc $CHROOT/proc/
sudo mount --bind /dev/pts $CHROOT/dev/pts
sudo mount --bind /run $CHROOT/run

# You can now use a chroot to apt install things here:
sudo cp script-to-run-in-chroot.sh $CHROOT
sudo chmod +x $CHROOT/script-to-run-in-chroot.sh
sudo chroot $CHROOT ./script-to-run-in-chroot.sh
sudo rm $CHROOT/script-to-run-in-chroot.sh

#Cleanup after yourself
sudo umount $CHROOT/dev/pts
sudo umount $CHROOT/dev/
sudo umount $CHROOT/sys/
sudo umount $CHROOT/proc/
sudo umount $CHROOT/run
sudo umount /dev/loop99p1
sudo umount /dev/loop99p2 -l
sudo losetup -d /dev/loop99

1 Like

re-reading my script I think I’ve also mis stated what I did, the first partition is the EFI partition, the second partition contains the kernel + rootfs

2 Likes

@steve84 I installed ubuntu via debootsrapping tool with the same partition table, then installed linux kernel using chroot.

Thanks a lot for your help!

But, I’ve got strange issue after mender-converting. Converting passed without any errors, but unfortunately, I get the next partition table in deployed image:

timandr@timandr-Latitude-5580:~/projects/iheart/menderimg/mender-convert$ fdisk -l deploy/mender-image-timandr-Latitude-5580-mender.img
The backup GPT table is corrupt, but the primary appears OK, so that will be used.
The backup GPT table is not on the end of the device. This problem will be corrected by write.
Disk deploy/mender-image-timandr-Latitude-5580-mender.img: 11,74 GiB, 12582912000 bytes, 24576000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: A333B69E-DF39-473A-A403-DEAAB8727A4E

Device                                                Start     End Sectors Size Type
deploy/mender-image-timandr-Latitude-5580-mender.img1  2048   92159   90112  44M EFI System
deploy/mender-image-timandr-Latitude-5580-mender.img2 92160 8388574 8296415   4G Linux filesystem

Somehow the GPT record is corrupted and there is only one rootfs :slight_smile:)

Partition table of the input image:

timandr@timandr-Latitude-5580:~/projects/iheart/menderimg/mender-convert/input$ fdisk -l mender-image.img
Disk mender-image.img: 4 GiB, 4294967296 bytes, 8388608 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: A333B69E-DF39-473A-A403-DEAAB8727A4E

Device            Start     End Sectors Size Type
mender-image.img1  2048   92159   90112  44M EFI System
mender-image.img2 92160 8388574 8296415   4G Linux filesystem

  1. Could you share how you install a kernel into the debootstrapped system?
  2. What do you think went wrong?

Below I share my mender-convert debug level logs.

Sorry that I’m asking you:) Probably you can help me to solve this issue.

2021-09-11 16:38:54 [INFO] [mender-convert-extract] Using configuration file: configs/mender_convert_config
2021-09-11 16:38:54 [INFO] [mender-convert-extract] Using configuration file: ./work/override_compression_config
2021-09-11 16:38:55 [INFO] [mender-convert-extract] Using configuration file: configs/mender_convert_config
2021-09-11 16:38:55 [INFO] [mender-convert-extract] Validating disk image
2021-09-11 16:38:55 [INFO] [mender-convert-extract] Disk parsed successfully
2021-09-11 16:38:55 [INFO] [mender-convert-extract] NUMBER OF PARTS: 2 TYPE: gpt
2021-09-11 16:38:55 [INFO] [mender-convert-extract] PART 1: SIZE: 44M TYPE: c12a7328-f81f-11d2-ba4b-00a0c93ec93b
2021-09-11 16:38:55 [INFO] [mender-convert-extract] PART 1: extracting to work/part-1.fs
2021-09-11 16:38:55 [DEBUG] [mender-convert-extract] Running: (modules/disk.sh:64): run_and_log_cmd():  


	dd if=input/mender-image.img of=work/part-1.fs skip=2048 bs=512 count=90112 conv=sparse status=none
2021-09-11 16:38:55 [INFO] [mender-convert-extract] PART 2: SIZE: 4G TYPE: 0fc63daf-8483-4772-8e79-3d69d8477de4
2021-09-11 16:38:55 [INFO] [mender-convert-extract] PART 2: extracting to work/part-2.fs
2021-09-11 16:39:05 [DEBUG] [mender-convert-extract] Running: (modules/disk.sh:64): run_and_log_cmd():  


	dd if=input/mender-image.img of=work/part-2.fs skip=92160 bs=512 count=8296415 conv=sparse status=none
2021-09-11 16:39:05 [INFO] [mender-convert-extract] Extracting boot gap to work/boot-gap.bin
2021-09-11 16:39:05 [DEBUG] [mender-convert-extract] Running: (modules/disk.sh:64): run_and_log_cmd():  


	dd if=input/mender-image.img of=work/boot-gap.bin skip=1 bs=512 count=2047 conv=sparse status=none
2021-09-11 16:39:05 [INFO] [mender-convert-modify] Using configuration file: configs/mender_convert_config
2021-09-11 16:39:05 [INFO] [mender-convert-modify] Using configuration file: ./work/override_compression_config
2021-09-11 16:39:05 [INFO] [mender-convert-modify] Using configuration file: configs/mender_convert_config
2021-09-11 16:39:10 [INFO] [mender-convert-modify] Installing Mender client and related files
2021-09-11 16:39:10 [INFO] [mender-convert-modify] Installing Mender client version latest
2021-09-11 16:39:11 [DEBUG] [mender-convert-modify] Running: (modules/deb.sh:42): run_and_log_cmd():  


	wget -Nq https://downloads.mender.io/repos/debian/dists/stable/main/binary-amd64/Packages -P /tmp
2021-09-11 16:39:18 [DEBUG] [mender-convert-modify] Running: (modules/deb.sh:50): run_and_log_cmd():  


	wget -Nq https://downloads.mender.io/repos/debian/pool/main/m/mender-client/mender-client_3.0.0-1_amd64.deb -P work/deb-packages
2021-09-11 16:39:18 [INFO] [mender-convert-modify] Successfully downloaded mender-client_3.0.0-1_amd64.deb
2021-09-11 16:39:18 [DEBUG] [mender-convert-modify] Running: (modules/deb.sh:104): run_and_log_cmd():  


	ar -xv /mender-convert/work/deb-packages/mender-client_3.0.0-1_amd64.deb
	x - debian-binary
x - control.tar.gz
x - data.tar.xz

2021-09-11 16:39:18 [DEBUG] [mender-convert-modify] Running: (modules/deb.sh:106): run_and_log_cmd():  


	sudo tar xJf data.tar.xz -C files
2021-09-11 16:39:18 [DEBUG] [mender-convert-modify] Running: (modules/deb.sh:109): run_and_log_cmd():  


	sudo rsync --archive --keep-dirlinks --verbose /tmp/tmp.3Nkof1vufe/files/ /mender-convert/work/rootfs/
	sending incremental file list
./
etc/
etc/mender/
etc/mender/artifact_info
etc/mender/scripts/
etc/mender/scripts/version
lib/
lib/systemd/
lib/systemd/system/
lib/systemd/system/mender-client.service
usr/
usr/bin/
usr/bin/directory-artifact-gen
usr/bin/docker-artifact-gen
usr/bin/mender
usr/bin/single-file-artifact-gen
usr/share/
usr/share/dbus-1/
usr/share/dbus-1/system.d/
usr/share/dbus-1/system.d/io.mender.AuthenticationManager.conf
usr/share/dbus-1/system.d/io.mender.UpdateManager.conf
usr/share/doc/
usr/share/doc/mender-client/
usr/share/doc/mender-client/changelog.Debian.gz
usr/share/doc/mender-client/copyright
usr/share/doc/mender-client/examples/
usr/share/doc/mender-client/examples/demo.crt
usr/share/doc/mender/
usr/share/mender/
usr/share/mender/identity/
usr/share/mender/identity/mender-device-identity
usr/share/mender/inventory/
usr/share/mender/inventory/mender-inventory-bootloader-integration
usr/share/mender/inventory/mender-inventory-geo
usr/share/mender/inventory/mender-inventory-hostinfo
usr/share/mender/inventory/mender-inventory-network
usr/share/mender/inventory/mender-inventory-os
usr/share/mender/inventory/mender-inventory-provides
usr/share/mender/inventory/mender-inventory-rootfs-type
usr/share/mender/inventory/mender-inventory-update-modules
usr/share/mender/modules/
usr/share/mender/modules/v3/
usr/share/mender/modules/v3/deb
usr/share/mender/modules/v3/directory
usr/share/mender/modules/v3/docker
usr/share/mender/modules/v3/rpm
usr/share/mender/modules/v3/script
usr/share/mender/modules/v3/single-file

sent 8,448,142 bytes  received 624 bytes  16,897,532.00 bytes/sec
total size is 8,443,824  speedup is 1.00

2021-09-11 16:39:18 [INFO] [mender-convert-modify] Successfully installed mender-client_3.0.0-1_amd64.deb into /mender-convert/work/rootfs/
2021-09-11 16:39:18 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:128): run_and_log_cmd():  


	sudo ln -sf /lib/systemd/system/mender-client.service         work/rootfs/etc/systemd/system/multi-user.target.wants/mender-client.service
2021-09-11 16:39:18 [INFO] [mender-convert-modify] Creating the Mender Configure state folder in the data partition
2021-09-11 16:39:18 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:170): run_and_log_cmd():  


	sudo mkdir -p work/rootfs/data/mender-configure
2021-09-11 16:39:18 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:171): run_and_log_cmd():  


	sudo ln -sf /data/mender-configure work/rootfs/var/lib/mender-configure
2021-09-11 16:39:20 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:177): run_and_log_cmd():  


	wget -Nq 'https://github.com/mendersoftware/grub-mender-grubenv/archive/aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1.tar.gz' -P work/
2021-09-11 16:39:20 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:178): run_and_log_cmd():  


	tar xzvf work/aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1.tar.gz -C work/
	grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/.gitignore
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/.gitlab-ci.yml
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/01_console_bootargs_grub.cfg
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/02_root_bootargs_grub.cfg
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/05_mender_setup_grub.cfg
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/06_systemd_machine_id_grub.cfg
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/10_bootargs_grub.cfg
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/90_mender_boot_grub.cfg
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/95_mender_try_to_recover_grub.cfg
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/99_mender_end_of_grub.cfg
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/LICENSE
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/LIC_FILES_CHKSUM.sha256
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/Makefile
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/README.md
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/blank_grubenv
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/fw_printenv
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/grub-efi/
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/grub-efi/Dockerfile.aarch64
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/grub-efi/Dockerfile.arm
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/grub-efi/Dockerfile.x86-64
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/grub-efi/docker-create-grub-efi-binaries
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/grub-efi/grub.inc
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/grub-efi/prepare-output-folder-for-upload
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/make-env-and-lock-files
grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/mender_grubenv_defines.example

2021-09-11 16:39:20 [INFO] [mender-convert-modify] Found Linux kernel image: 

	/mender-convert/work/rootfs/boot/vmlinuz-5.4.0-26-generic

2021-09-11 16:39:20 [INFO] [mender-convert-modify] Found initramfs image: 

	/mender-convert/work/rootfs/boot/initrd.img-5.4.0-26-generic

2021-09-11 16:39:20 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:200): run_and_log_cmd():  


	sudo ln -s vmlinuz-5.4.0-26-generic work/rootfs/boot/kernel
2021-09-11 16:39:20 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:202): run_and_log_cmd():  


	sudo ln -s initrd.img-5.4.0-26-generic work/rootfs/boot/initrd
2021-09-11 16:39:20 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:228): run_and_log_cmd():  


	make 2>&1
	rm -rf tmp-workdir
mkdir -p tmp-workdir
cp -f ./05_mender_setup_grub.cfg ./01_console_bootargs_grub.cfg ./99_mender_end_of_grub.cfg ./06_systemd_machine_id_grub.cfg ./95_mender_try_to_recover_grub.cfg ./10_bootargs_grub.cfg ./02_root_bootargs_grub.cfg ./90_mender_boot_grub.cfg tmp-workdir
cp -f mender_grubenv_defines tmp-workdir/00_mender_grubenv_defines_grub.cfg
cd tmp-workdir && for script in [0-9][0-9]_*_grub.cfg; do \
	echo "# Start of ---------- `basename $script` ----------"; \
	cat $script; \
	echo "# End of ---------- `basename $script` ----------"; \
done > mender_grub.cfg
mv tmp-workdir/mender_grub.cfg .
rm -rf tmp-workdir
echo "ENV_DIR = /boot/efi/EFI/BOOT" > mender_grubenv.config
./make-env-and-lock-files
+ BLANKENV=./blank_grubenv
++ sed -ne '/^mender_rootfsa_part=/ {s/^mender_rootfsa_part=//; p}' mender_grubenv_defines
+ PART_NUMBER=2
+ mkdir -p mender_grubenv
+ cp ./blank_grubenv mender_grubenv/env
++ grep '^######' -b mender_grubenv/env
++ egrep -o '^[0-9]+'
+ offset=25
+ dd of=mender_grubenv/env bs=25 seek=1 conv=notrunc
2+1 records in
2+1 records out
51 bytes copied, 3.5819e-05 s, 1.4 MB/s
+ cp ./blank_grubenv mender_grubenv/lock
++ grep '^######' -b mender_grubenv/lock
++ egrep -o '^[0-9]+'
+ offset=25
+ dd of=mender_grubenv/lock bs=25 seek=1 conv=notrunc
0+1 records in
0+1 records out
10 bytes copied, 3.0754e-05 s, 325 kB/s
+ cd mender_grubenv
+ sha256sum lock

2021-09-11 16:39:20 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:229): run_and_log_cmd():  


	sudo make DESTDIR=../ BOOT_DIR=boot install-boot-files
	install -d -m 755 ../boot/EFI/BOOT
install -m 644 mender_grub.cfg ../boot/EFI/BOOT/grub.cfg
install -m 755 -d ../boot/EFI/BOOT/mender_grubenv1
install -m 644 mender_grubenv/env ../boot/EFI/BOOT/mender_grubenv1/env
install -m 644 mender_grubenv/lock ../boot/EFI/BOOT/mender_grubenv1/lock
install -m 644 mender_grubenv/lock.sha256sum ../boot/EFI/BOOT/mender_grubenv1/lock.sha256sum
install -m 755 -d ../boot/EFI/BOOT/mender_grubenv2
install -m 644 mender_grubenv/env ../boot/EFI/BOOT/mender_grubenv2/env
install -m 644 mender_grubenv/lock ../boot/EFI/BOOT/mender_grubenv2/lock
install -m 644 mender_grubenv/lock.sha256sum ../boot/EFI/BOOT/mender_grubenv2/lock.sha256sum

2021-09-11 16:39:20 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:230): run_and_log_cmd():  


	sudo make DESTDIR=../rootfs install-tools
	install -d -m 755 ../rootfs/usr/bin
install -m 755 ./fw_printenv ../rootfs/usr/bin
ln -sf fw_printenv ../rootfs/usr/bin/fw_setenv
install -d -m 755 ../rootfs/etc
install -m 755 mender_grubenv.config ../rootfs/etc

2021-09-11 16:39:20 [INFO] [mender-convert-modify] Installing GRUB
2021-09-11 16:39:20 [INFO] [mender-convert-modify] GRUB EFI: bootx64.efi
2021-09-11 16:39:22 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:256): run_and_log_cmd():  


	wget -Nq https://downloads.mender.io/grub-mender-grubenv/grub-efi/2.04-grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/x86-64/grub-efi-bootx64.efi -P work/
2021-09-11 16:39:22 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:257): run_and_log_cmd():  


	wget -Nq https://downloads.mender.io/grub-mender-grubenv/grub-efi/2.04-grub-mender-grubenv-aa7e8f8c76c6aca6dca1820aaa42dc2cbf9762a1/x86-64/grub-editenv -P work/
2021-09-11 16:39:22 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:259): run_and_log_cmd():  


	sudo install -m 751 work/grub-editenv work/rootfs/usr/bin/
2021-09-11 16:39:22 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:261): run_and_log_cmd():  


	sudo mkdir -p work/boot/EFI/BOOT
2021-09-11 16:39:22 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:262): run_and_log_cmd():  


	sudo cp work/grub-efi-bootx64.efi -P work/boot/EFI/BOOT/bootx64.efi
2021-09-11 16:39:22 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:277): run_and_log_cmd():  


	sudo mkdir -p work/rootfs/data/mender
2021-09-11 16:39:22 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:278): run_and_log_cmd():  


	sudo ln -sf /data/mender work/rootfs/var/lib/mender
2021-09-11 16:39:23 [INFO] [mender-convert-modify] Using root device A in mender.conf: /dev/mmcblk0p2
2021-09-11 16:39:23 [INFO] [mender-convert-modify] Using root device B in mender.conf: /dev/mmcblk0p3
2021-09-11 16:39:23 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:290): run_and_log_cmd():  


	sudo cp work/mender.conf.data work/rootfs/data/mender/mender.conf
2021-09-11 16:39:23 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:291): run_and_log_cmd():  


	sudo chmod 600 work/rootfs/data/mender/mender.conf
2021-09-11 16:39:23 [INFO] [mender-convert-modify] Installing the local mender.conf file
2021-09-11 16:39:23 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:295): run_and_log_cmd():  


	mkdir -p work/rootfs/etc/mender
2021-09-11 16:39:23 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:296): run_and_log_cmd():  


	cp resources/mender.conf work/rootfs/etc/mender
2021-09-11 16:39:23 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:297): run_and_log_cmd():  


	sudo chmod 600 work/rootfs/etc/mender/mender.conf
2021-09-11 16:39:23 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:313): run_and_log_cmd():  


	echo 'device_type=timandr-Latitude-5580' > work/device_type
2021-09-11 16:39:23 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:314): run_and_log_cmd():  


	sudo install -m 0444 work/device_type work/rootfs/data/mender/
2021-09-11 16:39:23 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:318): run_and_log_cmd():  


	echo 'artifact_name=release-1'                      | sudo tee work/rootfs/etc/mender/artifact_info
	artifact_name=release-1

2021-09-11 16:39:23 [INFO] [mender-convert-modify] Creating state scripts version file.
2021-09-11 16:39:23 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:326): run_and_log_cmd():  


	sudo mkdir -p work/rootfs/etc/mender/scripts/
2021-09-11 16:39:23 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:327): run_and_log_cmd():  


	echo -n 3 | sudo tee work/rootfs/etc/mender/scripts/version
	3

2021-09-11 16:39:23 [INFO] [mender-convert-modify] Installing a custom /etc/fstab (see /mender-convert/logs/convert.log.ebdU for more info)
2021-09-11 16:39:23 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:337): run_and_log_cmd():  


	sudo mkdir -p work/rootfs//boot/efi
2021-09-11 16:39:23 [INFO] [mender-convert-modify] Using boot partition device in fstab: /dev/mmcblk0p1
2021-09-11 16:39:23 [INFO] [mender-convert-modify] Using data partition device in fstab: /dev/mmcblk0p4
2021-09-11 16:39:23 [INFO] [mender-convert-modify] Performing platform specific modifications (if any)
2021-09-11 16:39:23 [INFO] [mender-convert-modify] Running hook: platform_modify
2021-09-11 16:39:23 [INFO] [mender-convert-modify] Performing user/local specific modifications (if any)
2021-09-11 16:39:23 [INFO] [mender-convert-modify] Running hook: user_local_modify
2021-09-11 16:39:23 [INFO] [mender-convert-modify] Applying rootfs overlay: rootfs_overlay_demo/
2021-09-11 16:39:23 [DEBUG] [mender-convert-modify] Running: (./mender-convert-modify:391): run_and_log_cmd():  


	sudo rsync --archive --keep-dirlinks --verbose rootfs_overlay_demo// work/rootfs/
	sending incremental file list
./
.gitkeep
etc/
etc/hosts
etc/mender/
etc/mender/server.crt

sent 2,393 bytes  received 92 bytes  4,970.00 bytes/sec
total size is 2,077  speedup is 0.84

2021-09-11 16:39:23 [INFO] [mender-convert-modify] Performing overlay specific modifications (if any)
2021-09-11 16:39:23 [INFO] [mender-convert-modify] Running hook: overlay_modify
2021-09-11 16:39:23 [INFO] [mender-convert-package] Using configuration file: configs/mender_convert_config
2021-09-11 16:39:23 [INFO] [mender-convert-package] Using configuration file: ./work/override_compression_config
2021-09-11 16:39:23 [INFO] [mender-convert-package] Using configuration file: configs/mender_convert_config
2021-09-11 16:39:23 [e[1;33mWARNe[0m] [mender-convert-package] The allocated boot part size 0 MiB is too small.
2021-09-11 16:39:23 [e[1;33mWARNe[0m] [mender-convert-package] The actual boot part size is 44 MiB
2021-09-11 16:39:23 [e[1;33mWARNe[0m] [mender-convert-package] Will adjust MENDER_BOOT_PART_SIZE_MB automatically
2021-09-11 16:39:23 [e[1;33mWARNe[0m] [mender-convert-package] Consider adjusting the configuration file to avoid this message
2021-09-11 16:39:23 [INFO] [mender-convert-package] Rootfs filesystem size will be 802 MiB
2021-09-11 16:39:23 [INFO] [mender-convert-package] Creating a file-system image from: work/rootfs/data/
2021-09-11 16:39:23 [DEBUG] [mender-convert-package] Running: (modules/disk.sh:114): run_and_log_cmd():  


	dd if=/dev/zero of=work/data.img seek=262144 count=0 bs=512 status=none
2021-09-11 16:39:23 [DEBUG] [mender-convert-package] Running: (modules/disk.sh:128): run_and_log_cmd():  


	/sbin/mkfs.ext4 -q -F work/data.img 
2021-09-11 16:39:23 [DEBUG] [mender-convert-package] Running: (modules/disk.sh:143): run_and_log_cmd():  


	mkdir -p work/output
2021-09-11 16:39:23 [DEBUG] [mender-convert-package] Running: (modules/disk.sh:144): run_and_log_cmd():  


	sudo mount work/data.img work/output
2021-09-11 16:39:23 [DEBUG] [mender-convert-package] Running: (modules/disk.sh:145): run_and_log_cmd():  


	sudo rsync --archive --delete work/rootfs/data/ work/output/
2021-09-11 16:39:23 [DEBUG] [mender-convert-package] Running: (modules/disk.sh:146): run_and_log_cmd():  


	sudo umount work/output
2021-09-11 16:39:23 [INFO] [mender-convert-package] Creating a file-system image from: work/rootfs/
2021-09-11 16:39:23 [DEBUG] [mender-convert-package] Running: (modules/disk.sh:114): run_and_log_cmd():  


	dd if=/dev/zero of=work/rootfs.img seek=1643724 count=0 bs=512 status=none
2021-09-11 16:39:23 [DEBUG] [mender-convert-package] Running: (modules/disk.sh:128): run_and_log_cmd():  


	/sbin/mkfs.ext4 -q -F work/rootfs.img 
2021-09-11 16:39:23 [DEBUG] [mender-convert-package] Running: (modules/disk.sh:143): run_and_log_cmd():  


	mkdir -p work/output
2021-09-11 16:39:23 [DEBUG] [mender-convert-package] Running: (modules/disk.sh:144): run_and_log_cmd():  


	sudo mount work/rootfs.img work/output
2021-09-11 16:39:28 [DEBUG] [mender-convert-package] Running: (modules/disk.sh:145): run_and_log_cmd():  


	sudo rsync --archive --delete work/rootfs/ work/output/
2021-09-11 16:39:29 [DEBUG] [mender-convert-package] Running: (modules/disk.sh:146): run_and_log_cmd():  


	sudo umount work/output
2021-09-11 16:39:29 [INFO] [mender-convert-package] Copying root filesystem image to deploy directory
2021-09-11 16:39:29 [DEBUG] [mender-convert-package] Running: (./mender-convert-package:212): run_and_log_cmd():  


	cp --sparse=always work/rootfs.img deploy/mender-image-timandr-Latitude-5580-mender.ext4
2021-09-11 16:39:29 [INFO] [mender-convert-package] Writing Mender artifact to: deploy/mender-image-timandr-Latitude-5580-mender.mender
2021-09-11 16:39:29 [INFO] [mender-convert-package] This can take up to 20 minutes depending on which compression method is used
2021-09-11 16:39:35 [DEBUG] [mender-convert-package] Running: (configs/mender_convert_config:261): run_and_log_cmd():  


	mender-artifact --compression none       write rootfs-image       --file work/rootfs.img       --output-path deploy/mender-image-timandr-Latitude-5580-mender.mender       --artifact-name release-1        --device-type timandr-Latitude-5580
	Writing Artifact...
Version             	e[1;32m✓e[0m
Manifest            	e[1;32m✓e[0m
Manifest signature  	e[1;32m✓e[0m
Header              	0%                              50%                              100%
|---------------------------------|---------------------------------|
e[1;32m✓e[0m
Payload
......................................................................

2021-09-11 16:39:35 [INFO] [mender-convert-package] Creating Mender compatible disk-image
2021-09-11 16:39:35 [INFO] [mender-convert-package] Total disk size: 12000 MiB
2021-09-11 16:39:35 [INFO] [mender-convert-package]   Boot partition    48 MiB
2021-09-11 16:39:35 [INFO] [mender-convert-package]   RootFS partitions 5896 MiB x 2
2021-09-11 16:39:35 [INFO] [mender-convert-package]   Data partition    128 MiB
2021-09-11 16:39:35 [DEBUG] [mender-convert-package] Running: (./mender-convert-package:230): run_and_log_cmd():  


	dd if=/dev/zero of=deploy/mender-image-timandr-Latitude-5580-mender.img bs=512 count=0 seek=24576000 status=none
2021-09-11 16:39:35 [INFO] [mender-convert-package] Using input diskimage partition scheme (gpt)
2021-09-11 16:39:35 [INFO] [mender-convert-package] Writing GPT partition table
2021-09-11 16:39:36 [DEBUG] [mender-convert-package] Running: (./mender-convert-package:257): run_and_log_cmd():  


	/sbin/parted -s deploy/mender-image-timandr-Latitude-5580-mender.img mklabel gpt
2021-09-11 16:39:36 [DEBUG] [mender-convert-package] Running: (./mender-convert-package:258): run_and_log_cmd():  


	/sbin/parted -s deploy/mender-image-timandr-Latitude-5580-mender.img unit s mkpart ESP fat32 16384 114687
2021-09-11 16:39:36 [DEBUG] [mender-convert-package] Running: (./mender-convert-package:264): run_and_log_cmd():  


	/sbin/parted -s deploy/mender-image-timandr-Latitude-5580-mender.img set 1 boot on
2021-09-11 16:39:36 [DEBUG] [mender-convert-package] Running: (./mender-convert-package:265): run_and_log_cmd():  


	/sbin/parted -s deploy/mender-image-timandr-Latitude-5580-mender.img -- unit s mkpart primary ext4 114688 12189695
2021-09-11 16:39:36 [DEBUG] [mender-convert-package] Running: (./mender-convert-package:266): run_and_log_cmd():  


	/sbin/parted -s deploy/mender-image-timandr-Latitude-5580-mender.img -- unit s mkpart primary ext4 12189696 24264703
2021-09-11 16:39:36 [DEBUG] [mender-convert-package] Running: (./mender-convert-package:267): run_and_log_cmd():  


	/sbin/parted -s deploy/mender-image-timandr-Latitude-5580-mender.img -- unit s mkpart primary ext4 24264704 24526847
2021-09-11 16:39:36 [DEBUG] [mender-convert-package] Running: (./mender-convert-package:268): run_and_log_cmd():  


	/sbin/parted -s deploy/mender-image-timandr-Latitude-5580-mender.img print
	Model:  (file)
Disk /mender-convert/deploy/mender-image-timandr-Latitude-5580-mender.img: 12.6GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name     Flags
 1      8389kB  58.7MB  50.3MB               ESP      boot, esp
 2      58.7MB  6241MB  6182MB               primary
 3      6241MB  12.4GB  6182MB               primary
 4      12.4GB  12.6GB  134MB                primary

2021-09-11 16:39:36 [INFO] [mender-convert-package] Writing boot gap of size: 98304 (sectors)
2021-09-11 16:39:36 [DEBUG] [mender-convert-package] Running: (modules/disk.sh:102): run_and_log_cmd():  


	dd if=work/boot-gap.bin of=deploy/mender-image-timandr-Latitude-5580-mender.img seek=1 conv=notrunc status=none
2021-09-11 16:39:36 [DEBUG] [mender-convert-package] Running: (./mender-convert-package:298): run_and_log_cmd():  


	sudo umount -f work/boot
2021-09-11 16:39:36 [DEBUG] [mender-convert-package] Running: (./mender-convert-package:299): run_and_log_cmd():  


	sudo umount -f work/rootfs
2021-09-11 16:39:36 [INFO] [mender-convert-package] Writing boot partition image
2021-09-11 16:39:36 [DEBUG] [mender-convert-package] Running: (modules/disk.sh:102): run_and_log_cmd():  


	dd if=work/part-1.fs of=deploy/mender-image-timandr-Latitude-5580-mender.img seek=16384 conv=notrunc status=none
2021-09-11 16:39:36 [INFO] [mender-convert-package] Writing rootfsa partition image
2021-09-11 16:39:39 [DEBUG] [mender-convert-package] Running: (modules/disk.sh:102): run_and_log_cmd():  


	dd if=work/rootfs.img of=deploy/mender-image-timandr-Latitude-5580-mender.img seek=114688 conv=notrunc status=none
2021-09-11 16:39:39 [INFO] [mender-convert-package] Writing rootfsb partition image
2021-09-11 16:39:42 [DEBUG] [mender-convert-package] Running: (modules/disk.sh:102): run_and_log_cmd():  


	dd if=work/rootfs.img of=deploy/mender-image-timandr-Latitude-5580-mender.img seek=12189696 conv=notrunc status=none
2021-09-11 16:39:42 [INFO] [mender-convert-package] Writing data partition image
2021-09-11 16:39:42 [DEBUG] [mender-convert-package] Running: (modules/disk.sh:102): run_and_log_cmd():  


	dd if=work/data.img of=deploy/mender-image-timandr-Latitude-5580-mender.img seek=24264704 conv=notrunc status=none
2021-09-11 16:39:42 [INFO] [mender-convert-package] Performing platform specific package operations (if any)
2021-09-11 16:39:42 [INFO] [mender-convert-package] Running hook: platform_package
2021-09-11 16:39:42 [INFO] [mender-convert-package] Conversion has completed! \o/

It seems I used wrong mender-convert config file for my system (UpBoard with x64 CPU).

Image successfully converted using generic_x86-64_hdd_config. At least now I see two rootfs partitions in the output file as expected.

I suspect that I just don’t need to use boot gap in my case:

# Nothing to copy
MENDER_COPY_BOOT_GAP="n"

For reference I deploy the kernel with a bash script called install-kernel-chroot.sh with the following contents:

apt update
apt install -y \
  wget
apt --print-uris --yes install linux-image-generic linux-headers-generic | grep ^\' | cut -d\' -f2 > downloads.list
wget --input-file downloads.list
dpkg -i *.deb
rm *.deb

it’s called from the placeholder in the script I posted above like this:

sudo cp install-kernel-chroot.sh $CHROOT
sudo chmod +x $CHROOT/install-kernel-chroot.sh
sudo chroot $CHROOT ./install-kernel-chroot.sh
sudo rm $CHROOT/install-kernel-chroot.sh