返回文章列表文章索引阅读全文
STARBLOG / 阅读手记
FAQ & Tips

Check dd command write progress in Linux

Preface In Linux, there is a powerful tool called dd for manipulating disk images, which is absolutely fantastic. The only downside is that it doesn't display the operation progress. However, there are ways to work around this. Below are several methods to check the writing progress. Using the status option to view progress If you are using the GNU version of dd and your coreutils version is higher than 8.24, you can use the status option. For example: `sudo dd if=/dev/sda of=/dev/zero status=progress` The above command on Mac

曦远 (DealiAxy)约 4 分钟
目录5 个章节

Preface

Under Linux, there is a powerful tool called dd used for operating on disk images—it's truly an amazing utility. The only drawback is that it doesn't display progress during operations. However, there are workarounds for this. Below are several methods to check the writing progress.

status Option to Check Progress

If you are using the GNU version of dd and the coreutils version is higher than 8.24, you can use the status option. For example:

sudo dd if=/dev/sda of=/dev/zero status=progress

The command above will result in an error when executed on Mac OS X, because OS X uses the BSD version of the command line, not GNU. You can install GNU coreutils on Mac OS X or use the pv command introduced below.

pv command

sudo pv -tpreb /dev/sda | dd of=/dev/zero
sudo pv -tpreb /dev/sda | dd of=/dev/zero bs=4096 conv=notrunc,noerror

Using pv together with dialog can also display a progress bar dialog box:

 (sudo pv -n /dev/sda | dd of=/dev/zero) 2>&1 | dialog --gauge "dd process bar" 10 70 0

Using pkill to Print Progress

Open a new Shell and execute the following command to output progress information once per second:

watch -n 1 pkill -USR1 -x dd

References

http://blog.topspeedsnail.com/archives/8125 http://blog.topspeedsnail.com/archives/2748 http://blog.topspeedsnail.com/archives/9464 https://www.mobibrw.com/2017/7677

Check dd command write progress in Linux · StarBlog