Is there a method of getting a percentage on a DD in linux?
See answers from this question [1]
pv
For example you can use pv
before you start
sudo apt-get install pv # if you do not have it
pv < /dev/sda > /dev/sc3 # it is reported to be faster
pv /dev/sda > /dev/sc3 # it seems to have the same speed of the previous one
#or
sudo dd if=/dev/sda | pv -s 1844G | dd of=/dev/sdc3 # Maybe slower
Output [2]:
440MB 0:00:38 [11.6MB/s] [======> ] 21% ETA 0:02:19
Notes:
Especially for large files you may want to see man dd
and set the options needed to speed up all on your hardware, e.g. bs=100M
to set the buffer, oflag=sync
to count the effective bytes written, maybe direct
...
The option -s
only takes integer parameters so 1.8T-->1844G
.
As you can notice from the first lines you do not need dd
at all.
kill -USR1 pid
If you already launched the dd
command, once you have individuated its PID (Ctrl-Z +bg
and you read it , or pgrep ^dd
... ) you may send a signal USR1
(or SIGUSR1
, or SIGINFO
see below) and read the output.
If the PID of the program is 1234 with
kill -USR1 1234
dd
will answer on the terminal of its STDERR with something similar to
4+1 records in
4+0 records out
41943040 bytes (42 MB) copied, 2.90588 s, 14.4 MB/s
Warning: Under OpenBSD you may have to check in advance the behaviour of kill
[3]: use instead
kill -SIGINFO 1234
.
It exists the sigaction named SIGINFO
. TheSIGUSR1
one, in this case, should terminate the program (dd
)...
Under Ubuntu use -SIGUSR1
(10
).
My go-to tool for this kind of stuff is progress
:
This tool can be described as a Tiny, Dirty, Linux-and-OSX-Only C command that looks for coreutils basic commands (cp, mv, dd, tar, gzip/gunzip, cat, etc.) currently running on your system and displays the percentage of copied data. It can also show estimated time and throughput, and provides a "top-like" mode (monitoring).
It simply scans
/proc
for interesting commands, and then looks at directoriesfd
andfdinfo
to find opened files and seek positions, and reports status for the largest file.It's very light, and compatible with virtually any command.
I find it particularly useful because:
- compared to
pv
in pipe ordcfldd
, I don't have to remember to run a different command when I start the operation, I can monitor stuff after the fact; - compared to
kill -USR1
, it works on virtually any command, I don't have to always double-check the manpage to make sure I'm not accidentally killing the copy; also, it's nice that, when invoked without parameters, it shows the progress for any common "data transfer" command currently running, so I don't even have to look up the PID; - compared to
pv -d
, again I don't need to look up the PID.
Run dd
, then, in a separate shell, invoke the following command:
pv -d $(pidof dd) # root may be required
This will make pv obtain statistics on all the opened file descriptors of the dd
process. It will show you both where the read and write buffer sit.