How to show progress when using the 'dd' command
Using the dd command has the problem that it doesn't show any progress during its operation. Below will be 2 methods of showing the progress of dd.
Use the 'status' argument (from Coreutils 8.24+)
This method uses a new argument which has been implemented in the coreutils package from version 8.24 and up.
The dd command now has an extra argument called status. This arguments accepts the following values:
status=LEVEL
The LEVEL of information to print to stderr;
'none' suppresses everything but error messages,
'noxfer' suppresses the final transfer statistics,
'progress' shows periodic transfer statistics
Just an example of how to use the command is:
dd if=/dev/urandom of=/dev/null status=progress
It will then show the progress in the following way:
1948803584 bytes (1.9 GB, 1.8 GiB) copied, 358 s, 5.4 MB/s
Piping dd output through pv (Pipe Viewer)
This method uses an additional application called pv to provide output of the progress. To make use of this the pv package needs to be installed first.
Install the pv tool (if not already installed)
sudo apt-get install pv
Run the dd command combined with the pv command. This is done by first using dd for the input of the file/device, then pipe it to pv, and then pipe it back to dd to output it to a file/device.
dd if=/dev/urandom | pv | dd of=/dev/null
You will then get an output like below:
1,74MB 0:00:09 [ 198kB/s] [ <=> ]
If the size of the file is known the -s option of pv can be used to provide a size. This will alter the output to give a percentage and ETA.
sudo dd if=/dev/sdb | pv -s 2G | dd of=DriveCopy1.dd bs=4096
Will give the following output:
440MB 0:00:38 [11.6MB/s] [======> ] 21% ETA 0:02:19
If using a file as input the pv command can be used directly as input. It will automatically retrieve the file size.
pv image.iso | dd of=/dev/sdb bs=4096
Will give the following output:
440MB 0:00:38 [11.6MB/s] [======> ] 21% ETA 0:02:19