Help needed with partition layout / data auto resize

On a Raspberrpi 4 I am trying to get the partition layout defined as following on a 30GB image:

  • Boot partition 512 MB
  • Rootfs A+B partitions ~8GB each
  • Data partition can fill in the rest of the disk space (~15GB)

From what I can see the physical rootfs partition sizes are ~14GB each, see fdisk log. However I want each rootfs partition to be ~8GB.

I’ve followed the instructions on: Convert a Mender Debian image | Mender documentation and Variables | Mender documentation

My mender convert config:

cat configs/my_first_config

MENDER_BOOT_PART_SIZE_MB=512
MENDER_STORAGE_TOTAL_SIZE_MB=30000
MENDER_COMPRESS_DISK_IMAGE=none
IMAGE_ROOTFS_SIZE=8388608  # 8GB

source configs/raspberrypi4_config

Snippet from mender-convert log (complete log can be found here ):

2024-08-05 06:40:41 [INFO] [mender-convert-package] Rootfs filesystem size will be 8192 MiB
2024-08-05 06:40:41 [INFO] [mender-convert-package] Creating a file-system image from: work/rootfs/
2024-08-05 06:41:08 [INFO] [mender-convert-package] Copying root filesystem image to deploy directory
2024-08-05 06:41:13 [INFO] [mender-convert-package] Installing the bootstrap Artifact
2024-08-05 06:41:56 [INFO] [mender-convert-package] Creating a file-system image from: work/data/
2024-08-05 06:41:56 [INFO] [mender-convert-package] Writing Mender artifact to: deploy/golden-image-raspberrypi4-mender.mender
2024-08-05 06:41:56 [INFO] [mender-convert-package] This can take up to 20 minutes depending on which compression method is used
2024-08-05 06:44:10 [INFO] [mender-convert-package] Creating Mender compatible disk-image
2024-08-05 06:44:10 [INFO] [mender-convert-package] Total disk size: 30000 MiB
2024-08-05 06:44:10 [INFO] [mender-convert-package]   Boot partition    512 MiB
2024-08-05 06:44:10 [INFO] [mender-convert-package]   RootFS partitions 14668 MiB x 2
2024-08-05 06:44:10 [INFO] [mender-convert-package]   Data partition    128 MiB

Some basic info about the Rasbian OS on the Pi4:

$ uname -a
Linux cb 6.6.31+rpt-rpi-v7l #1 SMP Raspbian 1:6.6.31-1+rpt1 (2024-05-29) armv7l GNU/Linux

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Raspbian
Description:	Raspbian GNU/Linux 12 (bookworm)
Release:	12
Codename:	bookworm

Mounted rootfs partition is ~8GB:

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       7.8G  2.4G  5.1G  32% /
devtmpfs        3.7G     0  3.7G   0% /dev
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           1.6G  1.2M  1.6G   1% /run
tmpfs           5.0M   16K  5.0M   1% /run/lock
/dev/mmcblk0p4  108M   48K   99M   1% /data
/dev/mmcblk0p1  510M   89M  422M  18% /uboot
tmpfs           790M     0  790M   0% /run/user/1000

However physical rootfs partitions are ~14GB

$ sudo fdisk -l

Disk /dev/mmcblk0: 29.84 GiB, 32044482560 bytes, 62586880 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: dos
Disk identifier: 0xcdd1f482

Device         Boot    Start      End  Sectors  Size Id Type
/dev/mmcblk0p1 *       24576  1073151  1048576  512M  c W95 FAT32 (LBA)
/dev/mmcblk0p2       1073152 31113215 30040064 14.3G 83 Linux
/dev/mmcblk0p3      31113216 61153279 30040064 14.3G 83 Linux
/dev/mmcblk0p4      61153280 61415423   262144  128M 83 Linux

Statys of systemd-growfs@data.service

$ sudo systemctl status systemd-growfs@data.service
● systemd-growfs@data.service - Grow File System on /data
     Loaded: loaded (/run/systemd/generator/systemd-growfs@data.service; generated)
     Active: active (exited) since Thu 2024-07-04 01:18:20 BST; 1 month 1 day ago
       Docs: man:systemd-growfs@.service(8)
    Process: 285 ExecStart=/lib/systemd/systemd-growfs /data (code=exited, status=0/SUCCESS)
   Main PID: 285 (code=exited, status=0/SUCCESS)
        CPU: 62ms

Jul 04 01:18:19 cb systemd[1]: Starting systemd-growfs@data.service - Grow File System on /data...
Jul 04 01:18:20 cb systemd-growfs[285]: Successfully resized "/data" to 128.0M bytes.
Jul 04 01:18:20 cb systemd[1]: Finished systemd-growfs@data.service - Grow File System on /data.

Hi @kcleong,

Thanks for reaching out! Yeah that is a confusing situation, which I also experienced a couple of weeks ago. Didn’t get round to properly document it yet, sorry.

The solution is to configure the conversion something like this:

MENDER_STORAGE_TOTAL_SIZE_MB="30000"
MENDER_BOOT_PART_SIZE_MB="512"
MENDER_DATA_PART_SIZE_MB="1024"
# we want the root filesystem to fill up the partitions
IMAGE_ROOTFS_SIZE="-1"

This will create two equally sized root filesystem partitions of

((30000 - (512 + 1024)) / 2)MB =14232MB

If you want to shrink those, you need to increase either boot or data partition size. With 512MB for /boot being perfectly fine in most cases, to get 8GB root partitions you could choose:

(30000 - (512 + 2 * 8192)) = 13104

# which means
MENDER_DATA_PART_SIZE_MB="13104"

Hope this helps,
Josef