dd command displays the progress of the implementation of

Small partners are clear, dd command default is not to display the progress of implementation, after the execution is waiting, waiting, until the tears, until my heart hair plugs. In fact, we can use the command to display the progress or status, the following several ways. The system version is:

$ lsb_release -a
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.5 LTS
Release:        16.04
Codename:       xenial

Note: need root privileges when executing dd command.

dd received signal USR1

# 启动 dd 进程并将 dd 进程的 PID($!)保存到 shell 变量 PID
$ if=/dev/sda1 of=/dev/zero bs=4096 & PID=$!

# 每隔 2 秒向 dd 进程发送一个 USR1 信号,要求 dd 进程输出拷贝进度
$ while kill -USR1 $PID; do sleep 2; done

Use the status option

# GUN 的 dd 版本必须大于 8.24
$ dd --version
dd (coreutils) 8.25
Copyright (C) 2016 Free Software Foundation, Inc.

$ dd if=/dev/sda1 of=/dev/zero bs=4096 status=progress
2870411264 bytes (2.9 GB, 2.7 GiB) copied, 20 s, 144 MB/s

Use the command pv

$ pv -tpreb /dev/sda1 | dd of=/dev/zero
1.02GiB 0:00:08 [ 108MiB/s] [====>   ..............   ]  0% ETA 0:20:11

Gun coreutils installed in Mac OS X, you can use the status option, or use pv command displays the progress.

Guess you like

Origin blog.csdn.net/weixin_34258078/article/details/90780689