Mender-convert partition sizing is incorrect when partition order is changed

mender-convert v3.01

Using mender convert i would like to change the order of the partitions within the output disk image img file to the below. Basically i want Data to be partition 2 rather than partition 4 as standard. With the rootfs A and B partitions becoming 3 and 4.

I thought this would be possible by configuring the following options inside my mender-convert config file.

MENDER_STORAGE_DEVICE_BASE=/dev/sda
# Partition number of boot partition
MENDER_BOOT_PART_NUMBER="1"
# Partition number of root filesystem A
MENDER_ROOTFS_PART_A_NUMBER="3"
# Partition number of root filesystem B
MENDER_ROOTFS_PART_B_NUMBER="4"
# Partition number of persistent data partition
MENDER_DATA_PART_NUMBER="2"

While this does set the Data partition as partition 2, and rootfs A and B to partition 3 and 4. The size of the Data partition is the same as rootfs A. Rootfs B partition ends up being 128mb.

Below is my config file.

MENDER_STORAGE_DEVICE_BASE=/dev/sda
MENDER_DEVICE_TYPE="x86_64"


# CUSTOM SETTINGS START

# Total size of the physical storage medium that mender partitioned images
# will be written to, expressed in MiB.
MENDER_STORAGE_TOTAL_SIZE_MB=10000
# Device file corresponding to the root filesystem partitions, without number.
MENDER_STORAGE_DEVICE_BASE=/dev/sda
# Partition number of boot partition
MENDER_BOOT_PART_NUMBER="1"
# Partition number of persistent data partition
MENDER_DATA_PART_NUMBER="2"
# Partition number of root filesystem A
MENDER_ROOTFS_PART_A_NUMBER="3"
# Partition number of root filesystem B
MENDER_ROOTFS_PART_B_NUMBER="4"
# The size of each of the two rootfs filesystems, in KiB. If this is 0,
# mender-convert will use the size of the filesystem content as a basis. If the
# value is -1, mender-convert will use the maximum size that will fit inside the
# created partition.
IMAGE_ROOTFS_SIZE="-1"
# The file system will be grown to occupy the full block device. If the file
# system is already at maximum size, no action will be performed.
#
# This feature is utilizing x−systemd.growfs and will only work on systemd 242
# and newer and nothing will be done if an older systemd version is used.
MENDER_DATA_PART_GROWFS=n



# Install Mender client
#
MENDER_CLIENT_INSTALL="y"
MENDER_CLIENT_VERSION="latest"
# Install Mender Connect addon
#
MENDER_ADDON_CONNECT_INSTALL="y"
MENDER_ADDON_CONNECT_VERSION="latest"
# Install Mender Configure addon
#
MENDER_ADDON_CONFIGURE_INSTALL="n"
MENDER_ADDON_CONFIGURE_VERSION="latest"



# CUSTOM SETTINGS END


# Nothing to copy
MENDER_COPY_BOOT_GAP="n"

function platform_modify() {
    #
    # Make sure /lib64 exists since the Mender binary requires it.
    # Some systems put everything under /lib (ie Yocto) and a simple
    # symlink is enough to find everything Mender needs.
    #
    if [ ! -e work/rootfs/lib64 ]; then
        run_and_log_cmd "ln -s /lib work/rootfs/lib64"
    fi
}

This results in the following.

root@box:~# lsblk -o name,mountpoint,label,size,uuid
NAME   MOUNTPOINT LABEL   SIZE UUID
sda                     111.8G
|-sda1 /boot/efi  EFI     272M A38A-80E2
|-sda2 /data              4.7G 589fbf03-5e50-4a71-8a38-d26821524c68
|-sda3 /                  4.7G 589fbf03-5e50-4a71-8a38-d26821524c68
`-sda4                    128M 81470eef-d23a-4182-a2c3-ab11a2e72972

The problem being that the Data partition is 4.7G instead of 128M and the rootfs B partition is 128M when it should be 4.7G

Any help appreciated !

Thanks in advance !

Mender-convert was never prepared for changing the order I believe. As far as I know the default configuration has been so ubiquitous that it is not currently being tested with anything else. It’s probably not super hard to fix, if you want to dive into the code a little bit and submit a pull request. I assume it will require changes around here and some surrounding areas.