How do you monitor the progress of dd?
Update 2016: If you use GNU coreutils >= 8.24 (default in Ubuntu Xenial 16.04 upwards), see method 2 below for an alternate way to display the progress.
Method 1: By using pv
Install pv
and put it between input / output only dd
commands.
Note: you cannot use it when you already started dd
.
From the package description:
pv
- Pipe Viewer - is a terminal-based tool for monitoring the progress of data through a pipeline. It can be inserted into any normal pipeline between two processes to give a visual indication of how quickly data is passing through, how long it has taken, how near to completion it is, and an estimate of how long it will be until completion.
Installation
sudo apt-get install pv
Example
dd if=/dev/urandom | pv | dd of=/dev/null
Output
1,74MB 0:00:09 [ 198kB/s] [ <=> ]
You could specify the approximate size with the --size
if you want a time estimation.
Example Assuming a 2GB disk being copied from /dev/sdb
Command without pv
would be:
sudo dd if=/dev/sdb of=DriveCopy1.dd bs=4096
Command with pv
:
sudo dd if=/dev/sdb | pv -s 2G | dd of=DriveCopy1.dd bs=4096
Output:
440MB 0:00:38 [11.6MB/s] [======> ] 21% ETA 0:02:19
Other uses
You can of course use pv
directly to pipe the output to stdout:
pv /home/user/bigfile.iso | md5sum
Output
50,2MB 0:00:06 [8,66MB/s] [=======> ] 49% ETA 0:00:06
Note that in this case, pv
recognizes the size automatically.
Method 2: New status
option added to dd
(GNU Coreutils 8.24+)
dd
in GNU Coreutils 8.24+ (Ubuntu 16.04 and newer) got a new status
option to display the progress:
Example
dd if=/dev/urandom of=/dev/null status=progress
Output
462858752 bytes (463 MB, 441 MiB) copied, 38 s, 12,2 MB/s
From HowTo: Monitor the progress of dd
You can monitor the progress of dd
once it's running without halting it by using the kill
command to send a signal to the process.
After you start dd
, open another terminal and enter either:
sudo kill -USR1 $(pgrep ^dd$)
Or, if you're on BSD or OS X:
sudo kill -INFO $(pgrep ^dd$)
This will display the progress in the dd
terminal window without halting the process (by printing to its stderr stream). For example:
# dd if=/dev/urandom of=rando bs=1024 count=1048576
335822+0 records in
335821+0 records out
343880704 bytes (344 MB, 328 MiB) copied, 6.85661 s, 50.2 MB/s
If you would like to get regular updates of the dd
progress, then enter:
watch -n5 'sudo kill -USR1 $(pgrep ^dd$)'
watch
will probe the dd
process every -n seconds (-n5
= 5 seconds) and report without halting it.
Note the proper single quotes in the commands above.
A few handy sample usages with pv
and less typing or more progress then other answers:
First you will need to install pv
, with the command:
sudo apt-get install pv
Then some examples are:
pv -n /dev/urandom | dd of=/dev/null
pv -tpreb source.iso | dd of=/dev/BLABLA bs=4096 conv=notrunc,noerror
Note: the first sample is 5 characters less typing then dd if=/dev/urandom | pv | dd of=/dev/null
.
And my favorite for cloning a disk drive (replace X with drive letters):
(pv -n /dev/sdX | dd of=/dev/sdX bs=128M conv=notrunc,noerror) 2>&1 | dialog --gauge "Running dd command (cloning), please wait..." 10 70 0
source: http://www.cyberciti.biz/faq/linux-unix-dd-command-show-progress-while-coping/
Also for archiving myself.