Last Updated: February 25, 2016
·
1.029K
· ipoerner

Querying the dd command

Often times you'll find yourself dumping files from one place to another, or dumping a whole disk or partition for that matter. A pretty simple - hence popular - solution is to use the dd command on Unix-based operating systems for this task.

However, depending on the size of the disk, your specific parameters to dd, the maximum bandwidth of the underlying bus, and also the nature of the data being dumped, this process may require quite a long time - all without dd giving any valuable feedback on the current state of things.

Today I learned that sending dd a SIGINFO signal actually causes it to divulge what it's been up to. Simply retrieve the process id using ps -a and use that pid to send the signal:

$ kill -USR1 <pid>

Example:

$ dd bs=4096 if=/dev/urandom of=/dev/sdb
13656124+0 records in
13656123+0 records out
55935479808 bytes (56 GB) copied, 7984.45 s, 7.0 MB/s

2 Responses
Add your response

Love this nuance about dd! Been awhile since I used it. Thanks for reminding me.

FYI - use the USR1 signal on Linux and SIGINFO on OS X/BSD

Here's some a fun example backgrounding dd as well as the SIGINFO call:

dd if=/dev/zero of=/dev/null bs=512 &
pid=$!
while ps -a $pid > /dev/null 2>&1
do
  # throw away stderr if we kill dd between ps and kill -SIGINF
  kill -SIGINFO $pid 2>/dev/null 
  sleep 1
done &
sleep 5
kill $pid
over 1 year ago ·

You're right, thanks for reminding me about the existence of the SIGINFO signal. Indeed, some implementations of dd listen to that (non-POSIX) signal instead of USR1 in order to write the current input and output block counts to stderr. This seems to be the case for most BSD variants and Mac OS X, as you mentioned.

Thanks for the remark!

over 1 year ago ·