Wednesday, February 27, 2008

Today's dirty command-line trick: progress statistics for dd

Who has already been using dd for endless data transfer without really knowing what is happening ? That is rather annoying. Sure, when the target is a normal file, you can always use

watch ls -l target

But, that won't tell you the rate of transfer, and it won't work if the target is a special file (device, pipe, ...). Fortunately, dd accepts the USR1 signal to print out some small statistics... Well, combining that with the watch tricks gives this:

watch killall -USR1 dd

And there you go, dd is now regularly printing out statistics. Pretty neat, isn't it ?


waveblaster said...

You can pipe DD through PV (process viewer) for similiar function.


dd if=/dev/zero | pv | dd of=/tmp/demo bs=1M

Vincent Fourmond said...

That is very good, if you remembered about it before starting the lengthy dd ;-)...