Thursday, 13 August 2009

dd and SIGUSR1

One neat feature in the dd utility is the ability to send it SIGUSR1 and it will dump out the current I/O statistics. This is useful when one is dd'ing a large amount of data and one would like to know how much data has been transferred or you want to see the current I/O rate. Below is an example where I'm filling a raw disc with zeros:

$ sudo -i
# dd if=/dev/zero of=/dev/sdb bs=1M & ddpid=$!
# kill -USR1 $ddpid
320+0 records in
320+0 records out
335544320 bytes (336 MB) copied, 18.5097 s, 18.1 MB/s


  1. You might like `pv' (pipe viewer) which lets you show and limit the speed at which data is passing through any pipe on the command-line.

    See here and here for some more info and examples :)

  2. @Legooolas: Cool, thanks for that. Mind you, another tool in the pipeline does introduce more context switches, which some folk may find a little inefficient.

  3. @Colin : Compared to the disk I/O it's not going to make much difference :)

  4. @Legoolas - very true, but some would argue that on some very low power devices we need to think about saving every cycle we can - and context switches can be costly. But that's a moot point :-)