42

I want to make a USB bootable by cloning an image. I did some research and I haven't found a satisfactory way of making dd provide some feedback back to the console of how the progress is going.

Is there a way, built into the command to do this, aside from polling the PID via the ps command?

0

2 Answers 2

57

If you read man dd, it refers you to info coreutils 'dd invocation' which says, in part,

Sending an INFO signal to a running dd process makes it print I/O statistics to standard error and then resume copying. In the example below, dd is run in the background to copy 10 million blocks. The kill command makes it output intermediate I/O statistics, and when dd completes normally or is killed by the SIGINT signal, it outputs the final statistics.

 $ dd if=/dev/zero of=/dev/null count=10MB & pid=$!
 $ kill -s INFO $pid; wait $pid
 3385223+0 records in
 3385223+0 records out
 1733234176 bytes (1.7 GB) copied, 6.42173 seconds, 270 MB/s
 10000000+0 records in
 10000000+0 records out
 5120000000 bytes (5.1 GB) copied, 18.913 seconds, 271 MB/s

On systems lacking the INFO signal dd responds to the USR1 signal instead, unless the POSIXLY_CORRECT environment variable is set.

You can also try the status=progress option, which will display the info in real time:

[~]$ dd if=/dev/zero of=/dev/null count=10MB status=progress
4708234752 bytes (4.7 GB, 4.4 GiB) copied, 4 s, 1.2 GB/s
10000000+0 records in
10000000+0 records out
5120000000 bytes (5.1 GB, 4.8 GiB) copied, 4.3516 s, 1.2 GB/s
[~]$ 
2
  • nice solution. Please note that count is only for demonstration purposes and for me MB was not working. It expects a number. Also I do not have a progress option for status in my dd. A one-liner for observing dd would be 'while kill -0 $pid; do kill -s INFO $pid;done'
    – ukos
    Commented Aug 23, 2018 at 10:13
  • 6
    status=progress is probably what 99.99% of everyone is looking for, but reading about INFO and USR1 signals is nice, reminds me how little I know about everything
    – jsaddwater
    Commented Sep 11, 2018 at 7:28
29

There are several solutions available via google search.

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

(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

enter image description here

You may have to install dialog and pv

sudo apt-get install pv dialog
2
  • 1
    I really like this answer, but any comments on what the different values do? 10 70 0? etc? Commented Oct 22, 2021 at 0:10
  • See man dialog: Box Options All dialog boxes have at least three parameters: text the caption or contents of the box. height the height of the dialog box. width the width of the dialog box.
    – SaeX
    Commented 23 hours ago

Not the answer you're looking for? Browse other questions tagged .