GuestbookSign our guestbook ContactGet in touch with the authors ArchiveAll unixwerk articles since 2003
January 14, 2013

Mini Tip: Print I/O Statistics of a Running «dd» Process

If you want to create an exact copy from one partition to another, or if you want to fill a partition with random data dd is the tool of your choice.

To copy the contents of /dev/sda to /dev/sdb you would type

# dd if=/dev/sda of=/dev/sdb bs=4M

To fill /dev/sdb5 with random data as preparation to an encryption using cryptsetup you would type

# dd if=/dev/urandom of=/dev/sdb5 bs=4M

Depending on the disk size these command can take several hours and you won't see any progress. However, when the dd job terminates it will print a line like this:

743+0 records in
743+0 records out
3116367872 bytes (3.1 GB) copied, 88.7885 s, 35.1 MB/s

But if you want to fill a 2TB partition with random data and you want to know the progress while the dd command is still running how can you know how far it already came?

Sending a USR1 signal to a running 'dd' process makes it print I/O statistics to standard error without terminating the process. First find the PID of the running dd process:

# ps -ef | grep -w '[d]d'
root     12731 11445  0 21:51 pts/1    00:00:00 dd if=/dev/random of=/dev/sdb5 bs=4M

Sending a USR1 command to the process...

# kill -USR1 12731

will force the running dd process printing out progress statistics to stderr and continue working. The statistics appear on the terminal where you started the dd process not on the terminal you issued the kill command.

# dd if=/dev/urandom of=/dev/sdb5 bs=4M
0+1151 records in
0+1151 records out
9237 bytes (9.2 kB) copied, 0.391 s, 23.1 kB/s