Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

dd is a wonder allowing you to 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 it's progress. It just sits there at the cursor until the command finally finishes. So how does one monitor dd's progress?

share|improve this question

10 Answers 10

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.

Other uses

You can also use it to 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.

share|improve this answer
7  
pv bigfile.iso | dd of=/dev/yourdevice –  Ion Br. Dec 17 '13 at 21:02
4  
Note that the parameters for "dd" are appropriate in the first half (the input part of the pipe): dd if=/dev/zero bs=1M count=35000 | pv | dd of=VirtualDisk.raw. –  Sopalajo de Arrierez Mar 28 at 0:05
    
Can we do pv bigfile.iso | dd of=VirtualDisk.raw bs=1M count=35000 instead? –  SiddharthaRT Oct 20 at 12:10
    
pv bigfile.iso | dd of=VirtualDisk.raw bs=1M count=35000 works, verified. @SopalajodeArrierez, parameters can be given in the second dd. –  SiddharthaRT Oct 20 at 12:17
up vote 77 down vote accepted

From HowTo: Monitor the progress of dd

You can monitor the progress of dd without halting it by using the kill command.

To see the progress of dd once it's running, open another terminal and enter:

sudo kill -USR1 $(pgrep ^dd)

This will display dd progress in the dd terminal window without halting the process. 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.

share|improve this answer
3  
This worked, but a couple of comments. First of all, I'm not sure why you escaped your backticks (if it's for the SO editor, you did it incorrectly). Secondly I'd recommend using ^dd$, just in case something else is running with the prefix dd. Finally, you don't need sudo to send the USR1 signal. Otherwise, good answer, +1. –  gsingh2011 Jul 14 '13 at 20:25
    
@gsingh2011 For a description of why sudo is used and each command is placed as it is, read the article it's from (linked at the top of the answer) –  James Jul 17 '13 at 23:17
    
I've added an answer below where I wrap dd and pkill into a function that can be called more easily than trying to juggle separate commands. –  Robru Apr 11 at 0:43
    
What about just killall -USR1 dd? –  MadTux Jul 26 at 13:34
    
NB! This way interupts dd work under OSX. –  Speakus Nov 17 at 6:33

The best is using http://dcfldd.sourceforge.net/ it is easy to install through apt-get

share|improve this answer
1  
thanks for the pointer to dcfldd, very compatible with dd but some good new features. I especially like the standard progress. –  Floyd Dec 20 '13 at 9:46
2  
Why dcfldd isn't more well known is a complete mystery to me. –  Freedom_Ben Mar 3 at 14:00

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.

watch ls -l /pathtofile/filename
share|improve this answer
    
Also a viable method... –  hexafraction Dec 7 '12 at 21:59
    
Useful, though this doesn't necessarily work if you're piping the dd output to something other than a file (eg gzip'ing before writing it to disk). –  Wallacoloo Jul 3 at 3:32

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:

(pv -n /dev/sda | dd of=/dev/sdb bs=128M conv=notrunc,noerror) 2>&1 | dialog --gauge "Running dd command (cloning), please wait..." 10 70 0

http://s0.cyberciti.org/uploads/faq/2012/10/check-status-of-dd-in-progress.png

source: http://www.cyberciti.biz/faq/linux-unix-dd-command-show-progress-while-coping/

Also for archiving myself.

share|improve this answer
    
@probackup those edits are not really helpful - the bold adds nothing to the answer, in fact it makes it hard to read. –  Tim Aug 29 at 21:56

I have created bash wrapper over dd that will use pv to show progress. Put it into your .bashrc and use dd as usual:

# dd if=/dev/vvg0/root of=/dev/vvg1/root bs=4M
    2GB 0:00:17 [ 120MB/s] [===========================================================>] 100%            
0+16384 records in
0+16384 records out
2147483648 bytes (2.1 GB) copied, 18.3353 s, 117 MB/s

Source:

dd()
{
    local dd=$(which dd); [ "$dd" ] || {
        echo "'dd' is not installed!" >&2
        return 1
    }

    local pv=$(which pv); [ "$pv" ] || {
        echo "'pv' is not installed!" >&2
        "$dd" "$@"
        return $?
    }

    local arg arg2 infile
    local -a args
    for arg in "$@"
    do
        arg2=${arg#if=}
        if [ "$arg2" != "$arg" ]
        then
            infile=$arg2
        else
            args[${#args[@]}]=$arg
        fi
    done

    "$pv" -tpreb "$infile" | "$dd" "${args[@]}"
}
share|improve this answer
    
Good way but it does not work with commands like sudo or time. –  Speakus Nov 17 at 7:28
    
Put it into /usr/local/bin/dd with this on top: #!/bin/bash. On bottom: tmp=":${PATH}:"; tmp=${tmp/:/usr/local/bin:/:}; tmp=${tmp%:}; PATH=${tmp#:}; dd "$@" Or you may wish to hardcode dd location. Then use local dd=/usr/bin/dd. Don't forget to add executable bit: chmod +x /usr/local/dd. –  midenok Nov 19 at 7:06

simply hit :

ctrl + t

while it runs and it will output the progress

load: 1.51  cmd: dd 31215 uninterruptible 0.28u 3.67s
321121+0 records in
321120+0 records out
164413440 bytes transferred in 112.708791 secs (1458745 bytes/sec)
share|improve this answer
    
Doesn't work for me on Kubuntu Trusty. Possibly conflicting key bindings? –  jamadagni Nov 15 at 4:33
    
Great way. It works under OSX, but does not work under ubuntu 14.04 –  Speakus Nov 17 at 6:39

So today I got a little frustrated with trying to run kill in a loop while dd was running, and came up with this method for running them in parallel, easily:

function vdd {
    sudo dd "$@" &
    sudo sh -c "while pkill -10 ^dd$; do sleep 5; done"
}

Now just use vdd anywhere you'd normally use dd (it passes all arguments directly through) and you'll get a progress report printed every 5s.

The only downside is that the command doesn't return immediately when dd completes; so it's possible that this command can keep you waiting an extra 5s after dd returns before it notices and exits.

share|improve this answer

Or simply type this in another terminal:

watch -n 3 df

No complexities. . . just simply knowing your drive/partition is being filled.

3 is for a 3 sec interval. . . you can increase the frequency if you wish.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.