How do you handle personalization of SD cards

Hi,
currently we have the following workflow:
I download the ISO from the balena dashboard. Then, using balena preload, I’m injecting our app into the image.
Then, using balena Etcher, we are flashing our SD cards. Current setup allows flashing of 14 SD cards simultanously, with incredible speed (takes roughly 1 minute incl. verification)!!

But, we need to personalize our SD cards, meaning, we do the following steps (scripted):

# mount device, do some UUID generation etc.
# ...
balena device register $APP_NAME --uuid $DEVICE_UUID
# other balena calls for public_urls, tags, etc.
balena config generate --device $DEVICE_UUID --version $OS_VERSION --output config.json // and other params
cp config.json /Volumes/resin-boot/config.json
# unmount, cleanup, other stuff

This takes ~30-40 seconds and requires to swap each SD card individually, which is quite time consuming.

Did anyone find out, how to do this for multiple SD cards simulateously?

I somehow have the feeling that when I insert the SD cards in multiple card readers, it’s not predicatble, which SD card will be mounted to in which order.

I’d love to run the script for our setup of 14 SD cards and can then be sure, that I know, which SD card is which one.

Any thoughts?

Thanks
Fritz

Hey,

This is an interesting use-case, but today Etcher is writing a single image to multiple drives; you’d require it to write multiple images to multiple drives.

You can use the balena CLI to flash an image though, so possibly you could script that into your flow ^^ ?

Hi,
yes, we are first flashing the image to the cards - that works fine.
The question is not necessarily Etcher related, but more balena workflow related – that’s right :wink:

Question is just, if someone has an idea on how to know, which SD card is which one, then personalization would be easy, like putting config1 -> /dev/sdb1, config2 -> /dev/sdb2, etc.
But I need to know, which PHYSICAL SD card is /dev/sdb2 etc.

Any ideas?
Thanks and cheers!

Are you not able to simply check the config.json that was written to the card to identify the card? Maybe even comparing a simple md5 hash of the customized/per-customer config on the flasher vs. the one of the card(s)?

Hi,
of course, but that’s again another manual and time-consuming step.

Maybe I need to say it differently: we are flashing hundreds of cards, all shall be personalized and then put into a Raspberry Pi, which will get a QR code on it, so we can identify it. QR code contains the device UUID.

Right now, I take one sd card, personalize it and then we put it in the matching RPi. I’d like to streamline the process to personalize multiple at once and then put them all into the corresponding RPis at once.

Thanks

I somehow have the feeling that when I insert the SD cards in multiple card readers, it’s not predicatble, which SD card will be mounted to in which order.

I don’t think it is predictable on macOS or at least I don’t know how.

However, this should be possible on Linux using /dev/disk/by-path/xxxxx links to devices created by udev. The same path will always point to the same usb port. So you would need a script that would map the device path to the config, mount the boot partition on it, inject the config and unmount.

Hi,
hey, didn’t know that --> looks promising! Thanks!