Etcher behind the scenes


More of a curiosity/educational question. I have been using etcher for a lot of my raspberry pi projects and am very happy with it. I’ve been curious as to what commands it is running in the background. I have tried using a combination of Mac OS diskutil, dd via brew, and dcfldd via brew. Although, I have not be able to get my images to run on the pi as consistently as etcher.

I have tried and am currently using the etcher cli (Thank you for that!) , but was also curious to see if i can write a quick script to replicate it as well in bash on my computer. I have tried the following:

    eval "sudo diskutil eraseDisk free UNTITLED $device"    
    eval "sudo diskutil eraseDisk FAT32 RASPBIAN MBRFormat $device"

    echo "Unmounting the disc in prep for image burn"
    eval "sudo diskutil unmountDisk $device"
    sudo dcfldd if=$IMAGE_NAME of=/dev/disk2 of=/dev/disk3 bs=4M statusinterval=1 sizeprobe=if
    echo "External drive Found: $device: Mounting Disk"
    eval "sudo diskutil mountDisk $device"
    echo "adding .ssh file here"
    echo "Ejecting the disks now..."
    eval "diskutil eject $which_disk"

Any guidance would be appreciated, I’m sure its something small that I’m missing.


Etcher manually writes byte-to-byte much like dd does, with some added flavour like verifying the flashing process after it’s done.
You can check more on how the current writing process looks like here

Does Etcher do any block size detection to avoid write amplification that will prematurely wear out USB drives? See an example of such detection here,
Message noting write amplification if alignment (blocksize in/out) isn’t correct.
Message warning of excessive wear.

I have several flash drives that have started behaving poorly (won’t format with Gnome disks or other tools) but they were fine until I flashed an image using Etcher 1.3.1 or 1.4.6. The most recent one to die was using 1.4.6, but one that died mysteriously over the past few months was likely written using 1.3.1 since that was the previous version of the AppImage on my system.