Hi,
I’m trying to build an image configuring/building script to prepare SD card images for our balena devices and seem to have fallen down an undocumented hole. From other posts in this forum, I can see other people have fallen down a similar hole, but I don’t see anyone directly asking how they should do this. I would really expect this to be in the “masterclass” docs, given it’s semi-advanced, but the masterclass makes use of images from the dashboard!
As I originally understood it, I could build a usable image for a BalenaCloud-supported device using these steps:
balena os download --version latest --output balena.img
balena os build-config balena.img raspberrypi4-64 -o config.json
balena os configure balena.img --config config.json --app myapp
balena os preload balena.img --app myapp --commit current
and this would yield a balena.img file that’s roughly the same thing as downloading it from the cloud dashboard, which I could then burn to a card with etcher/dd/etc. Turns out this is false. It yields an image that’ll boot the device into a useless state of not registering with the cloud and not being reachable (because it’s not a dev image). I’m not even sure why balena os configure
takes --app
as an argument if that’s not the key bit of information it needs to write the app ID into the config in the image…
After a couple of days poking around in the balena source and inside a dev build of the balenaos, I found that balena os initialize
(which isn’t really documented) writes additional keys into config.json that tells the OS how to register with the cloud. But it also writes the image to a card at the same time. I don’t want to do that.
I see a few references in this forum to https://github.com/balena-io-modules/balena-register-device which seems to generate this config, in particular the API key. And it appears to be per-device?
I don’t want to burn device-specific IDs into the image because I need to mass-flash these images to cards, preferably not using the balena CLI.
I’d assumed a generic image would generate device-specific UUID and keys on first registration with the cloud (I see some references to this happening in other forum posts). Is this the case? Can I take the same image and burn it to a hundred cards and it’ll register each as a different UUID?
While I can use balena os initialize
to burn a card then take an image of that card, everything seems to be discouraging me from doing that, without any clear docs for balena-cli to say how this should happen.
I really think there needs to be “how to build a working balenaos image using the CLI” page in the docs somewhere, that explicitly mentions the role of balena os initialize
in making the image usable. I can’t be the only one that’s had this happen to them
Everything else about balena has been smooth and “behaves as expected”, so I really hope I can iron this out and get into prod.