How to set new partition size with mender-convert

I moved this to a separate topic as we are now entering more generic information.

Is there a way to tell mender-convert that I only want 4GB partitions?

Yes mender-convert has an option --storage-total-size-mb where you can specify a total size in MB, and this is used to calculate the partition sizes. There is also a variable to set the data part size (data-part-size-mb), typically you do not need to set this to a very high number as this will be expanded to occupy the “rest of the disk” on first boot.

To calculate rootfs partition size there is a simple formula,

rootfs partition size = (storage-total-size-mb - data-part-size-mb - boot part size (40MB)) / 2

But there is a caveat, rootfs partition size can not be smaller then the size of the input image.

I thought maybe raw-disk-image-shrink-rootfs was what I might want to use, but I’m not sure how to use it:

And this is where raw-disk-image-shrink-rootfs comes in, to be able to shrink the expanded image to actual size + 20 % free space, and then it can be resized using --storage-total-size-mb

Also the reason why your rootfs is 15GB is because by default Raspbian will also resize the rootfs partition on first boot to fill the disk, and I am assuming that you have a 16 GB SD card.

The command that you used to run raw-disk-image-shrink-rootfs is correct.

The problem you are seeing is fixed here. The reason that you are seeing this bug is that the mender-convert used for rpi0w is not the official mender-convert repository and is instead based on a fork. A link to a very long discussion on why can be found here.

If you look at the linked commit for the raw-disk-image-shrink-rootfs fix, you can easily patch that locally for now. But I am sure that @MarekBelisko will sync up his fork when he has some time.

1 Like