Image size created by mender-convert does not match MENDER_STORAGE_TOTAL_SIZE_MB

Hi,

I am trying to use mender-convert (latest 2.2.0) to convert a golden image of Raspbian buster lite for Raspberry Pi Zero Wifi. I thought I set it up correctly for a 16GB SD card, but the resulting image is… 17.18GB.

I set the following config values:

MENDER_STORAGE_TOTAL_SIZE_MB=“16384”
MENDER_BOOT_PART_SIZE_MB=“256”
MENDER_DATA_PART_SIZE_MB=“256”
IMAGE_ROOTFS_SIZE=0

I also got the following output:

2020-10-13 05:23:27 [INFO] [mender-convert-package] Using configuration file: configs/mender_convert_config

2020-10-13 05:23:27 [INFO] [mender-convert-package] Using configuration file: watt_config

2020-10-13 05:23:30 [INFO] [mender-convert-package] Rootfs filesystem size will be 3974 MiB

2020-10-13 05:23:30 [INFO] [mender-convert-package] Creating a file-system image from: work/rootfs/data/

2020-10-13 05:23:30 [INFO] [mender-convert-package] Creating a file-system image from: work/rootfs/

2020-10-13 05:27:25 [INFO] [mender-convert-package] Copying root filesystem image to deploy directory

2020-10-13 05:27:45 [INFO] [mender-convert-package] Writing Mender artifact to: deploy/101320-raspberrypi0w-mender.mender

2020-10-13 05:27:45 [INFO] [mender-convert-package] This can take up to 20 minutes depending on which compression method is used

2020-10-13 05:28:40 [INFO] [mender-convert-package] Creating Mender compatible disk-image

2020-10-13 05:28:40 [INFO] [mender-convert-package] Total disk size: 16384 MiB

2020-10-13 05:28:40 [INFO] [mender-convert-package] Boot partition 256 MiB

2020-10-13 05:28:40 [INFO] [mender-convert-package] RootFS partitions 7924 MiB x 2

2020-10-13 05:28:40 [INFO] [mender-convert-package] Data partition 256 MiB

2020-10-13 05:28:40 [INFO] [mender-convert-package] Using input diskimage partition scheme (dos)

2020-10-13 05:28:40 [INFO] [mender-convert-package] Writing DOS (MBR) partition table

2020-10-13 05:28:41 [INFO] [mender-convert-package] Writing boot partition image

2020-10-13 05:29:37 [INFO] [mender-convert-package] Writing rootfsa partition image

2020-10-13 05:53:19 [INFO] [mender-convert-package] Writing rootfsb partition image

2020-10-13 06:14:43 [INFO] [mender-convert-package] Writing data partition image

2020-10-13 06:14:43 [INFO] [mender-convert-package] Performing platform specific package operations (if any)

2020-10-13 06:14:43 [INFO] [mender-convert-package] Running hook: platform_package

2020-10-13 06:14:43 [INFO] [mender-convert-package] Compressing deploy/101320-raspberrypi0w-mender.img.gz

This already confused me:

Rootfs filesystem size will be 3974 MiB
RootFS partitions 7924 MiB x 2

So which is it? I expected 7924 since it is approximately (16GB - 256MB - 256MB)/2.

Is the incorrect final size of the image (17.18GB vs 16GB) related to the fact that a 16GB card is really 2^34 = 17179869184 bits? Not that this helps because I can’t in the end burn the image, it complains the size of the card is too small for the image.

Please let me know if I should provide other details. Thanks!

I think you need to set IMAGE_ROOTFS_SIZE to -1. WIth the value of 0, it will use the size of the input image partition rather than the calculated size.

Drew

Thanks for the quick reply.

I tried this now, but I still got an image that is 17.18GB instead of 16. The change I saw in the logs is:

Rootfs filesystem size will be 7924 MiB
RootFS partitions 7924 MiB x 2

So now these two match, which makes more sense.

Is there something else I need to set? Or do you think this is a bug?

I kept the two related flags set to their defaults:

IMAGE_ROOTFS_EXTRA_SPACE=“0”
IMAGE_OVERHEAD_FACTOR=“1.5”

Thanks

For further context, here is the complete config file I used:

RASPBERRYPI_CONFIG="raspberrypi0w"
RASPBERRYPI_KERNEL_IMAGE="kernel.img"
MENDER_KERNEL_IMAGETYPE=zImage
MENDER_DEVICE_TYPE="raspberrypi0w"

source configs/raspberrypi_config

# 16384 here produces disk which is 17.18GB
MENDER_STORAGE_TOTAL_SIZE_MB="16384"
MENDER_BOOT_PART_SIZE_MB="256"
MENDER_DATA_PART_SIZE_MB="256"

IMAGE_ROOTFS_SIZE=0

Indeed. 17179869184 is 16 * 2^30 = 16
I guess it is the difference between gigabyte and gibibyte.

Interestingly I did notice the following:

ls -l deploy/2020-05-27-raspios-buster-lite-armhf-raspberrypi0w-mender.img -rw-r--r-- 1 dmoseley dmoseley 17179869184 Oct 13 14:01 deploy/2020-05-27-raspios-buster-lite-armhf-raspberrypi0w-mender.img ls -lh deploy/2020-05-27-raspios-buster-lite-armhf-raspberrypi0w-mender.img
-rw-r–r-- 1 dmoseley dmoseley 16G Oct 13 14:01 deploy/2020-05-27-raspios-buster-lite-armhf-raspberrypi0w-mender.img

Thanks for clarifying, didn’t even know the term gibibyte haha! But yes I can confirm that I get this too for my image:

ls -l 101320-raspberrypi0w-mender.img
-rw-r--r--  1 oernst  staff  17179869184 Oct 12 23:32 101320-raspberrypi0w-mender.img

ls -lh 101320-raspberrypi0w-mender.img
-rw-r--r--  1 oernst  staff    16G Oct 12 23:32 101320-raspberrypi0w-mender.img

But ApplePiBaker isn’t too happy with that :confused:

Screen Shot 2020-10-13 at 11.30.04 AM

Sorry, I think I just got it.

So all the variables in the config file that are stated as …_MB are actually …_MiB? So if I really wanted a 16384 MB ~ 16GB card (which is probably a bit too big, since the actual size of a 16GB card is usually reported more like 14.8GB), then:

16GB = 15258 MiB

should be the actual value of MENDER_STORAGE_TOTAL_SIZE_MB. Is that correct?

I didn’t check the math but the principle is correct. The alternative would be to specify it as quite a bit smaller than the actual card size and then enable MENDER_DATA_PART_GROWFS to have the /data partition expanded at runtime to fill the balance of the media.

Thanks! That clears up my questions.

I wish the variables were named _MiB instead of MB haha, but probably it would be too confusing to change.

Thanks