ARM, linux, shell

Safely flash SD card images with ddsd

I would like to share another wrapper based on the pv command ( because we love progress bars!! ).

As part of my work in NextCloudPi, I am constantly copying images to an SD card to test the latest build. The classic Linux way of doing this is by using the dd command

We all know the caveats of using this command, namely

  • The syntax is ugly
  • Better not forget that last sync call
  • There is no safety check to prevent you to mistakenly overwriting your root partition
  • If the SD card showed up in a different place, let’s say /dev/sde, you end up with a new 4GB file in /dev/sdd, and still you think that the copy went well.
  • Even though we now have status=progress for dd, I still like the progress bar better.

Usage

The usage is simple

The only optional argument is the block size. For instance

As in the dd command, the optimum value for this parameter depends on the specifics of the operating system, buffers and hardware. If not specified, the following rule will be used ( from man pv )

The default buffer size is the block size of the input file’s filesystem multiplied by 32 (512KiB max), or 400KiB if the block size cannot be determined.

Installation

Get the script and make it executable. You can do this in two lines, but better inspect it first. Don’t trust anyone blindly.

Code

github

Author: nachoparker

Humbly sharing things that I find useful [ github dockerhub ]

Leave a Reply

Your email address will not be published. Required fields are marked *