dd
is a wonder. It lets you duplicate a hard drive to another, completely zero a hard drive, etc. But once you launch a dd
command, there's nothing to tell you of its progress. It just sits there at the cursor until the command finally finishes. So how does one monitor dd's progress?
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 onlydd
commands.Note: you cannot use it when you already started
dd
.From the package description:
Installation
Example
Output
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:Command with
pv
:Output:
Other uses
You can of course use
pv
directly to pipe the output to stdout:Output
Note that in this case,
pv
recognizes the size automatically.Method 2: New
status
option added todd
(GNU Coreutils 8.24+)dd
in GNU Coreutils 8.24+ (Ubuntu 16.04 and newer) got a newstatus
option to display the progress:Example
Output
From HowTo: Monitor the progress of dd
You can monitor the progress of
dd
once it's running without halting it by using thekill
command to send a signal to the process.After you start
dd
, open another terminal and enter either:Or, if you're on BSD or OS X:
This will display the progress in the
dd
terminal window without halting the process (by printing to its stderr stream). For example:If you would like to get regular updates of the
dd
progress, then enter:watch
will probe thedd
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:Then some examples are:
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):
source: http://www.cyberciti.biz/faq/linux-unix-dd-command-show-progress-while-coping/
Also for archiving myself.
For the sake of completeness:
Version 8.24 of the GNU coreutils includes a patch for dd introducing a parameter to print the progress.
The commit introducing this change has the comment:
Many distributions, including Ubuntu 16.04.2 LTS use this version.
Use Ctrl+Shift+T while
dd
is running, and it will output the progress (in bytes):The best is using http://dcfldd.sourceforge.net/ it is easy to install through apt-get
Native progress status was added to dd!!!
The new version of Coreutils (8.24) adds a progress status to the
dd
tool:Usage on Xubuntu 15.10:
Open a terminal and type these commands:
Run
dd
as root:You will see: Bytes, seconds and speed (Bytes/second).
To check the versions of
dd
:Native:
New:
If you have already started dd, and if you are writing a file such as when creating a copy of a pendrive to disk, you can use the watch command to constantly observe the size of the output file to see changes and estimate completion.
To see only file size (h-human view):
The
dd | pv | dd
triad made my 50GB vm copy take 800 seconds, as opposed to 260 seconds using just dd. With this pipeline, at least, pv has no idea how big the input file is so it won't be able to tell you how far along you are so there's no disadvantage to doing it as follows- and you get a nice speed advantage:I would avoid pv on anything large, and (if using Bash):
Control-Z the dd process
bg
to put it in background. Observe thatbg
will give you output like[1] 6011
where the latter number is a process id. So, do:while true; do kill -USR1 process_id ; sleep 5; done
where process_id is the process id you observed. Hit Control-C when you see something like:
You are done.
Edit: Silly Systems Administrator! Automate your life, don't work! If I have a long dd process that I want to monitor, here's a one-liner that will take care of the whole enchilada for you; put this all on one line:
You can, of course, script it, perhaps make $1 your input file and $2 your output file. This is left as an exercise for the reader. Note that you need that little sleep before the kill or the kill may die trying to send a signal to dd when it's not ready yet. Adjust your sleeps as desired (maybe even remove the second sleep altogether).
Bash- FTW! :-)
http://linuxcommando.blogspot.com/2008/06/show-progress-during-dd-copy.html
Basically: