Command line option

Is it possible to run Etcher via command line? Give the program the location of the image and the drive of the micro SD card?

I am trying to script the whole setup of our Raspberry Pi set up to make life easier for our Production people.

Hi, Etcher does not have a command-line interface at the moment, there was one but it was deprecated due to the lack of use.

balena CLI

You can likely use the balena CLI, probably, which uses etcher underneath:

~> balena local flash --help
Usage: local flash <image>

Use this command to flash a balenaOS image to a drive.

Examples:

	$ balena local flash path/to/balenaos.img[.zip|.gz|.bz2|.xz]
	$ balena local flash path/to/balenaos.img --drive /dev/disk2
	$ balena local flash path/to/balenaos.img --drive /dev/disk2 --yes

Options:

    --drive, -d <drive>                 drive                              
    --yes, -y                           confirm non-interactively          

This local flash command should provide all the things you needed?

Etcher SDK

You can also make a simple command line interface using Node.js and the Etcher SDK

This could be used to put together a small tool to do the image burn on the command line, asked our team members for a simple example, that etcher-sdk codebase has some examples too, but doesn’t seem to me that there’s one that is directly usable to as you wanted.

Does this help?

I will give it a whirl thanks

We are using etcher CLI in our workflow to flash our devices, just wanted to let you know. While you of course have the stats for how many people are actually using it, I just wanted to reinforce that there are people who are actually using it.

While I generally would discourage using old versions of software, for anyone stumbling upon this and in absolute need of using it, the last version over at GitHub is v.1.4.9 and we are currently using that version to flash our devices.

2 Likes

Can you provide any insight or tips in how you’re using both the CLI and possibly the older version to flash devices via the command line? I’ve been happy with using Etcher via the desktop, but I need to now automate a workflow and the GUI version is just not feasible any longer. Thanks!

Yes, we have the similar case, want to make this progress automation for the production application. Have you completed it?

Hey guys,

As mentioned above with the man page for balena local flash, you can automate flashing local disks with balena local flash /path/to/image.img --drive /path/to/drive --yes. Is there something specifically we can further help clarify?

Hello everyone,

Is there a way to flash system drives with this ‘balena local flash’ command? This is a requirement for us.

Thank you,
Jared

Hello Jared,

Just to clarify, are you trying to flash a system drive on the same device that is running balena-cli?

Hi @imrehg and @Tschebbischeff ,

Does the balena cli support flashing multiple devices at the same time like the etcher?

balena local flash path/to/balenaos.img --drive /dev/sda --drive /dev/sdb 

I want to use automate the process of using balena etcher just like the users above, but I am flashing multiple Cm4 devices at the same time

Hi,

No it does not. Only one --drive argument is processed. You can still automate the process, it’ll just require a separate flash for each of the drives.

I am using Balena Etcher GUI to flash iot devices, it’s took about 3 minutes to decompress flash and validate. I need to automate this process, so I tried Balena CLI and it took about 18 minutes to but only performing two action flashing and validate, without decompressing. Any idea how to accelerate it?