creating flasher image file from running Beaglebone

What’s the easiest way to create a Beaglebone flasher image file from a running system? I currently use the script to directly write to a microSD card. I then use dd to copy the microSD card to a file. I currently only have a 32GB microSD card, though, so when I copy it the file is 32GB. With compression that mostly goes away, but and I’d also like it to work with smaller cards than that. Any ideas what the ideal solution is?

You should be able to use gparted to shrink the partition size down,
then just dd to the last sector used.. (untested in theory..)


How about changing the partition size in the make flasher script? Could there be an option to make it the same size as the eMMC? Where is the partition size determined?

LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__

Change to:
${sfdisk_boot_startmb},${some new var for size},${sfdisk_fstype},*


Thanks Robert! I issued a pull request with a couple minor changes to add a variable where you explained:

Here’s the text of the pull request that describes how it could be used to make a smaller image size than the size of your microSD card:

Setting the conf_rootfs_partition_size variable allows for better control over the size of the microSD card necessary to house the resulting image when running the script. For example, you might be working with a 32GB microSD card image, but want to generate an image that would also fit on a 4GB microSD card, so you could do the following:
sudo conf_rootfs_partition_size=7462912 /opt/scripts/tools/eMMC/

Which would specify the size as 7462912 sectors, which is the size of the eMMC rootfs partition (at least on the one I was testing on). After making the flasher you could then use dd to get the image off the microSD card for flashing onto other microSD cards:

sudo dd if= of= bs=512 count=7471104

7471104 can be determined by the output from fdisk -l (one more than the End sector, or 8192 more than the size of the rootfs partition):
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 * 8192 7471103 7462912 3.6G 83 Linux

You may be able to speed up the dd command by using a bigger blocksize and adjusting the count accordingly (using a 4MB block size):
sudo dd if= of= bs=419430 count=912

Thanks all merged up!

PS, you can add the variable to /boot/