I am copying this .img file to my USB flash drive using dd command. How can I check its progress ?
-
The "this question already has answers here" is a different question, and the answers are different to the answers here.Graham Leggett– Graham Leggett2024-06-05 06:39:28 +00:00Commented Jun 5, 2024 at 6:39
3 Answers
If you write to a slow drive, for example a USB drive, you may want to know not only the progress of the command dd itself, but also the progress of actual writing to the target device.
You can modify the dd command line to make it flush the buffers regularly, for example after writing each mibibyte, and at the same time show the progress, for example
sudo dd if=file.img bs=1M of=/dev/sdx status=progress oflag=dsync
Please check and double-check, that you specify the correct target device. Otherwise you might overwrite valuable data. dd does what you tell it to do without any questions.
Edit: You can find several other methods in my answer as well as other answers at this link.
dd by default uses 512 bytes blocks to copy data which could result in slow data transfers and increased CPU usage. I often prefer to use cat or pv instead, e.g.
pv -petrab img-file > /dev/sdc1
-
1On really slow disks like this one ancient USB stick I use for installing systems (because it's not useful for anything else!) the buffer might end up absorbing the entire write. I use the
-Yoption to causepvto callfdatasync()after eachwrite:-petrabY. This gives me a much more accurate speed reading without making me wonder how long it takes to sync the disk as pv exits.Mingye Wang– Mingye Wang2024-06-17 05:40:15 +00:00Commented Jun 17, 2024 at 5:40
The easiest way to do this is by using progress in the status flag, it will display the seconds elapsed and speed of copying on your terminal.
sudo dd if=img-file of=/dev/sdc1 status=progress