How to flash an image to a specific size

I’ve got a question that doesn’t seem to be on the internet. A lot of people want to expand their partition size because 4GB can be limiting. My question is the opposite, I want to be able to shrink it. Every single time, while flashing, it (logically) expands the partition to the maximum amount of space. How can I install say a clean debian image onto the eMMC storage on the BeagleBone Black that is exactly 1.9GB?

Hi @aslansutu another user wanted that same feature, so they added it back on April 22nd 2021…

In /boot/ add a variable conf_rootfs_partition_size with an integer value in MB’s (correction sectors)…


1 Like

The pull request gives an example of how to do it manually: added conf_rootfs_partition_size by jallwine · Pull Request #124 · RobertCNelson/boot-scripts · GitHub

Note that this method requires setting up a Beaglebone through the standard method and then rips the image off the eMMC and stores it with a specific rootfs size to an inserted microSD card. Then you can use that microSD card to flash the eMMC.

1 Like

In /boot/ add a variable conf_rootfs_partition_size with an integer value in MB’s…

I believe the conf_rootfs_partition_size is the number of 512 byte sectors.

@pocketnc_john good point… i was looking at sfdisk_boot_startmb, then I see, i postfix “M” on it… So yes conf_rootfs_partition_size is a sector number, unless you add an M or G at the end…


    echo_broadcast "==> sfdisk parameters:"
    echo_broadcast "sfdisk: [$(LC_ALL=C sfdisk --version)]"
    echo_broadcast "sfdisk: [sfdisk ${sfdisk_options} ${destination}]"
    echo_broadcast "sfdisk: [${sfdisk_boot_startmb},,${sfdisk_fstype},*]"
    echo_broadcast "==> Partitionning"
    generate_line 60
    LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__