[Bash] How to show information about dd progress / statistics
dd is a great tool for low-level copying and conversion of raw data. It can be also used for data erasure. Unfortunately, it doesn’t show any information about progress of copying.
Here is my little, but useful script:
1 2 3 4 5 6 7 8 9 10 | #!/bin/bash # dd.sh Author: Wojtek Jamrozy (www.wojtekrj.net) dd $* & pid=$! sleep 10 while [ -e "/proc/$pid" ] ; do kill -USR1 $pid sleep 10 done |
Line 4 executes dd with arguments of dd.sh at the background, and stores PID of dd process in $pid variable
In line 7 while checks if /proc/$pid exists. If exsists, process $pid is still running.
Line 8 is executed every 10 secunds and tell dd to show information about progress.
Example of usage:
$ ./dd.sh if=/dev/zero of=/dev/null count=50000000
11282170+0 przeczytanych recordów
11282169+0 zapisanych recordów
skopiowane 5776470528 bajtów (5,8 GB), 10,0174 s, 577 MB/s
22557922+0 przeczytanych recordów
22557922+0 zapisanych recordów
skopiowane 11549656064 bajty (12 GB), 20,0196 s, 577 MB/s
33852540+0 przeczytanych recordów
33852540+0 zapisanych recordów
skopiowane 17332500480 bajtów (17 GB), 30,0219 s, 577 MB/s
45151438+0 przeczytanych recordów
45151437+0 zapisanych recordów
skopiowane 23117535744 bajty (23 GB), 40,024 s, 578 MB/s
50000000+0 przeczytanych recordów
50000000+0 zapisanych recordów
skopiowane 25600000000 bajtów (26 GB), 44,321 s, 578 MB/s