User avatar
rin67630
Posts: 460
Joined: Fri Mar 04, 2016 10:15 am

Creating a SD image suitable for Balena Etcher

Tue Aug 13, 2019 2:33 pm

Hi
I would like to create a SD image of my ready configured RPi that is suitable for Balena Etcher
I tried dd but the generated of= file will not work on Balena, it does not issue an error, but stays forever and writes nothing to the SD card.

Who knows, how to make a balena compatible file?

Andyroo
Posts: 4189
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Creating a SD image suitable for Balena Etcher

Tue Aug 13, 2019 3:43 pm

Have a look at https://www.raspberrypi.org/forums/view ... 8#p1511694

It’s not on GITHUB just a zip and to be honest I’ve not tried it yet but the author is still on here :lol:
Need Pi spray - these things are breeding in my house...

drgeoff
Posts: 9744
Joined: Wed Jan 25, 2012 6:39 pm

Re: Creating a SD image suitable for Balena Etcher

Tue Aug 13, 2019 5:21 pm

rin67630 wrote:
Tue Aug 13, 2019 2:33 pm
Hi
I would like to create a SD image of my ready configured RPi that is suitable for Balena Etcher
I tried dd but the generated of= file will not work on Balena, it does not issue an error, but stays forever and writes nothing to the SD card.

Who knows, how to make a balena compatible file?
That should work.

However, even when you succeed with that you need to be aware that dd creates an image file which is the same size as the actual capacity of the card it reads. When you come to write that image file to another card, using dd, cp, Etcher or any other method, that second card needs to have an actual capacity no smaller than the first one. Cards are marked with nominal capacity and it is rare for two cards, even from the same silicon wafer, to have exactly equal actual capacities,

bls
Posts: 211
Joined: Mon Oct 22, 2018 11:25 pm

Re: Creating a SD image suitable for Balena Etcher

Tue Aug 13, 2019 7:54 pm

If you have a Linux (or Raspbian Pi) system on which to write the SD card, you can definitely do it with dd. No need to use Etcher. Here's the script I use.

Code: Select all

#!/bin/bash
# $1 input zip file
# $2 output device (/dev/sde, for example)

[ "$1" == "" ] && echo "% Zip file required" && exit
[ "$2" == "" ] && echo "% Output device required" && exit
unzip -p $1 | dd bs=4M of=$2 iflag=fullblock oflag=direct status=progress
To use it, put it in a convenient directory (I use /usr/local/bin and make sure that's in my path), and then (where /dev/sdf is my SD card):

Code: Select all

ddpizip /path/to/2019-07-10-raspbian-buster-lite.zip /dev/sdf

drgeoff
Posts: 9744
Joined: Wed Jan 25, 2012 6:39 pm

Re: Creating a SD image suitable for Balena Etcher

Tue Aug 13, 2019 11:59 pm

@bls

Read the first post again.

RonR
Posts: 479
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Creating a SD image suitable for Balena Etcher

Wed Aug 14, 2019 12:40 am

rin67630 wrote:
Tue Aug 13, 2019 2:33 pm
Hi
I would like to create a SD image of my ready configured RPi that is suitable for Balena Etcher
I tried dd but the generated of= file will not work on Balena, it does not issue an error, but stays forever and writes nothing to the SD card.

Who knows, how to make a balena compatible file?

You cannot use dd to make an image file of a running system. The resulting image file will be corrupt.

Image File Utilities contains image-backup which will create a backup image file of a running system. The image file created can later be written to an SD card (or USB device) with Etcher and booted normally. image-backup can also be used to incrementally update an existing image file.

Simply run image-backup with no parameters to create an initial backup. You will be asked for an image file size which defaults to the size of the media being backed up. You can specify 0 to see the minimum size required. If you don't plan to update the image file, the minimum size is probably what you want. If you plan to incrementally update the image file, specify a size substantially larger than the minimum to allow for expansion. After the initial backup, you can incrementally update the image file by running image-backup with a parameter of the image filename.

I set up a cron job to incrementally update my backup image file every day at 4 AM so I always have a current backup.

bls
Posts: 211
Joined: Mon Oct 22, 2018 11:25 pm

Re: Creating a SD image suitable for Balena Etcher

Wed Aug 14, 2019 12:43 am

drgeoff wrote:
Tue Aug 13, 2019 11:59 pm
@bls

Read the first post again.
Oops. Obviously missed an important part. I dd my nicely-configured SD card to somewhere using dd, and then dd it back into new cards. Never mind.

PhatFil
Posts: 1342
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Creating a SD image suitable for Balena Etcher

Wed Aug 14, 2019 1:43 am

etcher wants an image file so a quick google for how to create an image file from a SD card revelled under windows win32diskimager is the tool to use and under *nix the dd command in the format

Code: Select all

dd if=/dev/sdc/ of=/home/sdcard.img 
should do it?

User avatar
rin67630
Posts: 460
Joined: Fri Mar 04, 2016 10:15 am

Re: Creating a SD image suitable for Balena Etcher

Wed Aug 14, 2019 9:42 am

PhatFil wrote:
Wed Aug 14, 2019 1:43 am
etcher wants an image file so a quick google for how to create an image file from a SD card revelled under windows win32diskimager is the tool to use and under *nix the dd command in the format
dd should do it?
I tried that, did not work.

Additionally that does mostly not work that way

Code: Select all

dd if=/dev/sdc/ of=/home/sdcard.img 
unless you have an external target that is big enough.

If you write the image on your own partition it will crash!
If you want to do it the right way, it is a bit more tricky:
First you need to optimize the partition and erase all unused space, unless your image will be much bigger than necessary.
Then you can dd that partition to another one preferably piping the "of" through gzip.

But... been there, done that. It did not work.
Balena etcher accepts the file, but stays on Start forever...

User avatar
rin67630
Posts: 460
Joined: Fri Mar 04, 2016 10:15 am

Re: Creating a SD image suitable for Balena Etcher

Wed Aug 14, 2019 2:26 pm

bls wrote:
Wed Aug 14, 2019 12:43 am
Oops. Obviously missed an important part. I dd my nicely-configured SD card to somewhere using dd, and then dd it back into new cards.
Then using the SD copier is far easier!
Making images is intended to distribute an image to non Linux aware people, who will just be able to run Balena etcher on Win**ws.

bls
Posts: 211
Joined: Mon Oct 22, 2018 11:25 pm

Re: Creating a SD image suitable for Balena Etcher

Thu Aug 15, 2019 3:23 am

rin67630 wrote:
Wed Aug 14, 2019 2:26 pm
Making images is intended to distribute an image to non Linux aware people, who will just be able to run Balena etcher on Win**ws.
This clarifies your use case, and I agree that something like Etcher is certainly better for Windows users than trying to get dd installed on Windows for a bunch of novice users. :)

That said, I haven't read and fully analyzed these threads, but there seem to be some concerns about Etcher out there. For instance, https://forums.balena.io/t/balenaetcher ... ssue/22620 and https://forums.balena.io/t/serious-priv ... 1-4-4/4103.

If I were using Etcher I would certainly want to understand these in detail, as they appear to be worthy of some concern.

Return to “Advanced users”