Quantcast
Channel: Davide’s blog
Viewing all articles
Browse latest Browse all 23

Monitor the progress of dd command

$
0
0

dd is a very useful command to clone disks; however, given the typical size of modern disks, it can easily run for hours without any output. A simple trick allows us to monitor the progress of the cloning.

I will present here three methods to monitor the status of dd; only the first can be used after the command has been launched.

1. Using kill command with USR1 signal
Despite its name, the command kill can send any signal to a process; actually, if it weren’t for its default signal being TERM it could as well being renamed sendsignal. Signal USR1 is a generic signal indicating user-defined conditions; together with USR2 it is used to extend the original set of available signals. Every program can interpret SIGUSR1 and SIGUSR2. When dd receives USR1 signal it displays the current status in the same terminal where it was launched.
So, to monitor the progress of dd launch this command from another terminal:
sudo kill -USR1 $(pgrep ^dd)
If you want to have regular updates you can use the command watch:
watch -n5 'sudo kill -USR1 $(pgrep ^dd)'
where -n5 means “every 5 seconds”; pay attention to the single quotes.
NOTE: BSD or OSX users shall use INFO instead of USR1, because USR1 signal will terminate dd.

2. Using command pv (Pipeline Viewer)
Install command pv with sudo apt-get install pv and use it in conjunction with dd as follows:
dd if=/dev/urandom | pv | dd of=/dev/null
The output will be something like:
1,74MB 0:00:09 [ 198kB/s] [ <=> ]
If you know the size in advance, you can use parameter -s or --size to allow pv to make an estimation of the remaining time:
sudo dd if=/dev/sdb | pv -s 2G | dd of=DriveCopy1.dd bs=4096
440MB 0:00:38 [11.6MB/s] [======> ] 21% ETA 0:02:19

3. Using dd with status option (GNU Coreutils 8.24+ only)
dd if=/dev/urandom of=/dev/null status=progress
462858752 bytes (463 MB, 441 MiB) copied, 38 s, 12,2 MB/s

Source: AskUbuntu


Viewing all articles
Browse latest Browse all 23