Update: See comments for a much better (and prettier!) way to do it with pipe viewer. Thanks Bill!
So you’re wiping a drive or writing an image using ‘dd‘ (dataset definition) and you’re not sure where it’s up to. There’s no built in way to check the progress (until it’s finished), so I use kill and pgrep.
On one terminal, run your dd command., something like this:
dd if=/dev/zero of=/dev/sdX bs=4096
On a second terminal, run the following:
kill -USR1 `pgrep ^dd`
Back on terminal one, it should spit out where it’s up to but keep on dd’ing away, like so:
2202+0 records in
2202+0 records out
2308964352 bytes (2.3 GB) copied, 24.3584 s, 94.8 MB/s
This only works with one instance, for multiple instances get the right dd or use a for loop to check them all.
Try using pipe viewer (pv) to display the progress in real time:
cat /dev/zero | pv -brt | dd of=/dev/sdX bs=4096
You can also display a progress bar if you know the size of the drive:
cat /dev/zero | pv -brtp -s 80g | dd of=/dev/sdX bs=4096
Wow, thanks Bill! I had no idea about pipe viewer, it’s great!
-c
Thanks for the tip. So I created a script, /usr/local/bin/ddp, which looks like this:
#!/bin/sh
# usage: ddp source dest
cat ${1} | pv -brtp -s `du -b ${1}` | dd of=${2} bs=4096
Since dd is usually just for copying images to physical media anyway, typing “ddp file /dev/whatever” is now both less cumbersome and more informative than plain dd.
Nice