Floating Octothorpe

dd progress

dd is a great tool for creating bootable media. For example putting raspbian onto an SD card is just a case of running:

dd if=2016-05-27-raspbian-jessie-lite.img of=/dev/sdd bs=4M

By default dd prints nothing until it has finished copying. If you have a large image, or if the device you're copying to has no status LED this isn't ideal. Thankfully there are a few ways around this.

Note: Make sure you are writing to the correct block device, dd will happily overrite your system disk if you tell it to! Checking /proc/partitions or running dmesg might be helpful.

Kill signals

The kill command can be used for more than just stopping processes. You can send any signal including SIGUSR1 (check signal(7) for more info). If you do this dd will print I/O stats to stderr then continue copying:

# Find the pid
$ pgrep '^dd$'
22410

# Send SIGUSR1 to dd using kill
$ kill -USR1 22410

You should then get output similar to the following:

330+1 records in
330+1 records out
1387266048 bytes (1.4 GB) copied, 80.9681 s, 17.1 MB/s

If you want to run this every 30 seconds you can do something like:

while [ "$(pgrep '^dd$')" ]; do
  kill -USR1 $(pgrep '^dd$')
  sleep 30
done

Using pv

You can also use the pv command if it's installed:

dd if=2016-05-27-raspbian-jessie-lite.img | pv | dd of=/dev/sdd bs=4M

Doing this will give you a progress bar similar to the following:

43MiB 0:00:06 [7.2MiB/s] [    <=>               ]

Because you're using two dd processes, you will end up with I/O stats being printed from each process. To suppress this you can use status=none:

dd if=2016-05-27-raspbian-jessie-lite.img status=none | pv | dd of=/dev/sdd bs=4M

New status option

If you're using a later version of dd (Coreutils 8.24+) you can also just use status=progress:

dd if=2016-05-27-raspbian-jessie-lite.img of=/dev/sdd bs=4M status=progress

This will print I/O stats regularly while dd is copying data:

10485760 bytes (10 MB, 10 MiB) copied, 0.703711 s, 14.9 MB/s

You can check the version of Coreutils you are using by running dd --version.