We're an ISO27001:2013 Certified Supplier

blog-post-featured-image

The venerable dd command has been a staple of Unix systems since the 5th Edition, released in 1974. It reads blocks from an input file and outputs them to a destination, so although it has rather unusual options compared to modern conventions, it’s still extremely useful for duplicating or transforming disk images.

However, one function which was missing from dd for a long time is a progress indicator. There are two ways to make up for this deficiency depending if you have a modern version of dd or you are stuck with an older operating system.

First, let’s recap a couple of common usage patterns for dd itself.

Basic dd operation

dd‘s most basic function is to take an input file (remember, in Unix almost everything is a file) and stream its contents to another file. That can be in one operation thus:

dd if=/dev/zero of=/dev/null

That operation can also be broken into a pipeline of two dd commands, which gives us the opportunity to insert other processing into the pipeline:

dd if=/dev/zero | dd of=/dev/null

pv to the rescue

Pipeviewer, or pv, is another small utility which takes standard input and passes it on through standard output, but here’s the magic: it can output a progress bar along the way. If the size of the file is known in advance then the progress bar is accurate; if not, it simply slides from side to side to indicate activity (and provides other information such as transfer rate).

A generic progress bar can be inserted into a dd pipeline directly:

dd if=/dev/zero | pv | dd of=/dev/null

Or, when the input is a normal file, pv can read it directly and then the progress bar is accurate:

pv my-disk-image.img | dd of=/dev/null

dd‘s own progress

Newer versions of dd have a progress bar built in; it’s a simple extra switch to enable this:

dd if=/dev/zero of=/dev/null status=progress

 

Photo by SioraPhotography on Unsplash

Secure. Reliable. Scalable.

If that doesn't describe your current Linux systems, check out our FREE Linux Survival Guide to help you get your systems up to scratch today!
  • This field is for validation purposes and should be left unchanged.