Mender-growfs-data and extra partitions

I have an embedded ZyboZ7 board running Yocto Zeus. It boots from a 4GB SDcard and I’m getting the following error from the mender-grow-data.service:

mender-client-resize-data-part[92]: Error: Can’t have overlapping partitions.

This systemd service calls:

/usr/bin/mender-client-resize-data-part

Which in turn tries to resize (grow) my ‘data’ partition (5):

/usr/sbin/parted -s /dev/mmcblk0 resizepart 5 100%

My Mender configuration adds an extra partition using the MENDER_EXTRA_PARTS mechanism. Here is my configuration:

# Mender Configuration

# The Mender storage device.
MENDER_STORAGE_DEVICE = "/dev/mmcblk0"

# Size of the memory device in MiB.
MENDER_STORAGE_TOTAL_SIZE_MB = "3700"

# Partition alignment
MENDER_PARTITION_ALIGNMENT = "4096"

MENDER_BOOT_PART_SIZE_MB = "16"
MENDER_BOOT_PART = "${MENDER_STORAGE_DEVICE_BASE}1"
MENDER_ROOTFS_PART_A = "${MENDER_STORAGE_DEVICE_BASE}2"
MENDER_ROOTFS_PART_B = "${MENDER_STORAGE_DEVICE_BASE}3"
# An extra partition will result in the creation of an extended msdos
# partition in place of the primary partition typically used by the
# Mender 'data' partition. By default 'data' partition starts at "4" but it
# is now an extended partition. The "new" data partition will now
# shift to partition "5" and subsequent extra partitions will follow
# afterwards (e.g. "6", "7", ...).
MENDER_DATA_PART = "${MENDER_STORAGE_DEVICE_BASE}5"
MENDER_DATA_PART_FSTAB_OPTS_append = ",sync"

# Extra partitions
MENDER_EXTRA_PARTS = "dante"
MENDER_EXTRA_PARTS[dante] = "--label=dante --fstype=ext4"
MENDER_EXTRA_PARTS_SIZES_MB[dante] = "4"
MENDER_EXTRA_PARTS_FSTAB[dante] = "auto defaults,sync"

MENDER_ARTIFACT_NAME = "${DISTRO}-2021-05-18"

MENDER_FEATURES_ENABLE_append = " mender-image mender-image-sd mender-client-install mender-uboot mender-systemd mender-growfs-data"

# This needs equal (2 * (BOOTENV_SIZE + (BOOTENV_SIZE % MENDER_PARTITION_ALIGNMENT)))
MENDER_RESERVED_SPACE_BOOTLOADER_DATA = "262144"

And my SDCard partitioning looks like the following:

# parted /dev/mmcblk0 unit s print
Model: SD SA04G (sd/mmc)
Disk /dev/mmcblk0: 7626752s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start     End       Size      Type      File system  Flags
 1      520s      33287s    32768s    primary   fat16        boot, lba
 2      33288s    3670271s  3636984s  primary   ext4
 3      3670272s  7307255s  3636984s  primary   ext4
 4      7307263s  7577607s  270345s   extended               lba
 5      7307264s  7569407s  262144s   logical   ext4
 6      7569416s  7577607s  8192s     logical   ext4

So basically, the data and dante partitions (5 & 6) are part of an extended msdos partition (4). The error occurs when parted attempts to grow the data partition but cannot because the dante partition follows immediately after it. It seems this is the issue. Ideally I want the data partition to follow the dante partition (rather than vice-versa) so it could grow. Is there any way to configure Mender to place the data partition after the extra partitions so that it can grow automatically? Are extra partitions incompatible with auto growing the data partition?

Hi @gschmott

As far as I can understand, as it is now, the data partition extension is incompatible with the extra partitions.

But I’m not intricately familiar with the image functionality.

Perhaps @kacf could help shed some further light on the issue?

Hi @oleorhagen -

This is what I understand as well after seeing the error reported in the systemd logs. I was hoping there was a work-around other than disabling the auto-growth functionality and doing a better job estimating the size I need up-front for the data partition.

Hoping someone else can suggest a work-around :wink:

I would say you have 2 possible work-arounds,

  1. Investigate how to bbappend the mender yocto recipes to fix up the necessary files to target the last a partition for growth rather than the data partition
  2. disable mender growfs and add you own system service that handles growing the last partition and its file system on boot.

That’s the thing, I do not want the dante (extra) partition to grow but rather only the data partition. What this means is always placing the extra partitions before the data partition so that data can be grown into the unused space. I suspect this is easier said than be done and likely requires more than a bbappend fix since (if I recall) much of the functionality is located in a Mender bbclass.

I wouldn’t have to disable Mender’s growfs systemd service if I could move the data partition after the extra partitions. But this essentially is the crux of the problem - the placement of the extra partitions in relation to the data partition.

Oh I see, sorry I misunderstood your requirements

Yeah, this isn’t supported at the moment. What would be great is if this section could take into account which number the MENDER_DATA_PART variable has, and use that to place the partition appropriately. This would require changing and probably splitting up this function into two parts, one for before the data partition, and one for after. It would have to take into account extended partitions too.

A pull request for this would be appreciated!

1 Like