Thursday, 18 July 2013

dd where are you upto ?

Just wanted to copy a USB drive to another one this evening (due to upgrading a USB 3.0 unit) and found the dd was taking quite a while (due to the USB 2.0 stick it was coming off, that and the fact the drives were 32GB) and so I looked for a way to see what dd was doing.

It turns out that to get dd to spit out its state you have to do a special trick with the kill command (usually used to stop un-responsive/runaway processes).


To get the info you will need two terminal windows (or you could use screen to hold the dd process).
In one terminal session start the dd process ie. dd if=/dev/sdX of=/dev/sdY.

Then in the other terminal session do this;
Lookup the process id of dd by doing typing in
pgrep -l '^dd$
This will net you the process id of dd, now put the process id in the following command (in this example I got "3479 dd" as the output of "pgrep -l '^dd$")
then type in
kill -USR1 3479
don't miss the -USR1 bit or you will kill the dd session.

each time you use the above command it causes dd to spit out its status into its running terminal session (that's the one you ran dd in at the start of this process), so switch over and have a look, you should see somthing like this
shadow@webX$ sudo dd if=/dev/sdX of=/dev/sdY
0+14 records in
0+14 records out
204 bytes (204 B) copied, 24.92 seconds, 0.0 kB/s
just hop back to the other terminal session and run the kill -USR1 ... command again each time you want to see where its up to

No comments:

Post a Comment