No space left on device while downloading container

You are right. I have to check why it doesn’t work with resindataexpander as the partition is expanded but not the filesystem.

I finally found my problem. When flashing eMMC with Stm32CubeProgrammer the last partition will take all space that are left.
https://wiki.st.com/stm32mpu/wiki/STM32CubeProgrammer_flashlayout#Partition_sizes

This will prevent balena to expand the data partition as it is already expanded.
The problem is that the partition is expanded but not the filesystem.

To reduce the size of the last partition, you can use an ‘Empty’ partition and leave it unused in the flashlayout, but that will not work with balena partition expander as there is no space left on disk.

So what could be best workaround for this?

I guess with disregard to modification of the partition size before flashing - you would need to write a script that would - after the first boot - delete the empty flagged partition and upon reboot let the balena expand script run again?

I solved it by creating a small initramfs module that run resize2fs.