Printing dd status

I recently used dd to zero out some hard drives on my Fedora Core workstation, and found that this operation takes a good deal of time (even when large blocksizes are used, it still takes a while). The dd utility doesn’t report status information by default, but when fed a SIGUSR1 signal it will dump the status of the current operation:

$ dd if=/dev/zero of=/dev/hda1 bs=512 &

$ kill -SIGUSR1 1749
1038465+0 records in
1038465+0 records out
531694080 bytes (532 MB) copied, 11.6338 seconds, 45.7 MB/s

It still amazes me how much stuff I have left to learn about the utilities I use daily.

13 Comments

boycat  on July 26th, 2006

short version: good for linux, don’t try on OSX. :)

long version:

i found this entry looking for a way to find out how long this dd i am currently running was going to take. my command ‘dd bs=512 if=/dev/disk3 of=/dev/disk2 conv=noerror,sync’ was meant to clone the failing drive in my powerbook (attached in firewire target mode (disk3) to my workstation powerbook) to another attached drive of identical geometry also on firewire (disk2).

i played with lsof and a few other commands in an attempt to derive total capacity or blocks or something in hex and compare them to the number of instruction calls dd has performed… and was getting WAY in depth on this. I decided there should be a simpler way … I should have known – BSD != linux. ;)

kill -SIGUSR1 will cause abrupt termination of dd with the result “User defined signal 1″.

WHoops! Now I gotta start over.

Good learning experience though.

I know there’s stuff like “Carbon Copy Clone” for OSX but i refuse to believe a good dessert can’t be made from a recipe of dd, disklabel, diskutil, and a sprinkle of some other stuff without using some GUI that removes you from what’s really happening underneath.

but.. just in case anyone else finds this, is using OSX, and wants to try it – beware, you might be starting your dd over again. in my case, i was 2 hrs into it. :) doh!

-jre

boycat  on July 26th, 2006

as a followup to my last comment… this worked
(gosh, helps to read man pages – commands differ on different OSes. whod’a thunkit?)
$ kill -s SIGINFO 9923
and on my other screen window:
$ dd bs=512 if=/dev/disk3 of=/dev/disk2 conv=noerror,sync
8550657+0 records in
8550656+0 records out
4377935872 bytes transferred in 2619.316508 secs (1671404 bytes/sec)

Yay. getting there! (darn slow FireWire v1 drives)
-jre

Chris Farhood  on February 4th, 2009

-SIGINFO will get you the status on OS X (at least in 10.5)

randoman  on June 4th, 2009

It is useful to use this command with the command ‘watch’.

for some reason it did not work for me to do this:

watch -n 30 kill -SIGUSR1 1234

Instead I had to do this:

watch -n 30 kill -USR1 1234

-n 30 specifies for the action to be performed every 30 seconds

As should be clear from the article 1234 should be replaced with whatever the process id of dd is. (use ‘top’ or ‘ps -e’ to find pid)

Aaron Belafonte  on August 31st, 2009

I was not able to execute any of these commands successfully on OS X 10.5. Does anyone have any insight as to why NONE of these are working?

rvw  on December 19th, 2009

On 10.6 use:

kill -s INFO dd-pid

and you can use

ps waux | grep dd

to find the pid of dd. (second number is the pid)

Wesley  on March 18th, 2010

Or you can skip all that pid crap and use pkill:

watch -n 5 pkill -SIGUSR1 dd

Boom, status updates every 5 seconds

Hugo  on April 7th, 2010

or you could follow the example in the frickin’ man page:
dd if=whatever of=whatever; pid=$!
Now you have the PID for DD in $pid
kill -USR1 $pid

Xell  on March 31st, 2011

Nice – worked on Ubuntu just fine!

kelvan  on June 25th, 2011

works on debian/ubuntu, terminates dd on Fedora15 :(

drue  on September 6th, 2011

On OS X and FreeBSD it’s even easier – just use ctrl-t interactively to get SIGINFO from dd or any other utility that supports it. No background/kill necessary.

slorinc  on September 16th, 2011

on OSX you might have to add “sudo” before the commands

thomas  on October 17th, 2011

Hi,

for a nice status information with estimited time remaining use pv: http://www.ivarch.com/programs/pv.shtml

Leave a Comment