I'm trying to use dd with pv to write an iso to a usb drive. I did:
iso="myiso.iso"; dd if="$iso" bs=1M | pv --eta --size $(ls -l "$iso" | awk '{print $5}') --progress --bytes --rate --wait > /dev/sdg
Following this guide:
https://gist.github.com/rriemann/1406035
However, what happens is that the iso is "written" very quickly according to the output of pv. I'm guessing it's all put into disk cache or similar. Then pv just hangs. ps shows that pv is still running, but dd isn't. I tried stracing pv, but there is no output, and strace hangs as well! ctrl+c has no effect on strace. In fact, it does not respond to signals 15, 3, 2, or 1. Waited a few minutes for each signal. I was eventually forced to send 9.
According to this:
http://www.reddit.com/r/linux/comments/1xvr25/linux_tip_dont_use_kill_9/
The strace binary is badly behaved.
Here are my questions:
-
How can I make pv report more useful data? I know it is probably doing what it is "supposed to", ie, just reporting on bytes that it pipes. But that is not helpful for what I want to know, which is rough estimate for bytes written to usb drive, eta, etc.
-
Why is strace not responding to any signals? My guess is that strace waits for a system call from the process it is watching before handling the next signal, which I would consider a bug. But that is just a guess. strace version 4.5.20.
Best Answer
Maybe you could put
dd
on the other end of the stick and try to avoid caches by using itsdirect
andsync
flags.With that you should be caching at most
dd
's blocksize, in this case1M
... well plus whatever is in the pipe|
itself I guess.