5 ms·
If all you are doing is the above, then you don't need dd at all. pv will act like dd (but with stdin/out) and uses a sensible buffer size you can override. Y
by rogerbinns 11y ago
If all you are doing is the above, then you don't need dd at all. pv will act like dd (but with stdin/out) and uses a sensible buffer size you can override. Your first example becomes:
pv --buffer-size 1m < /dev/sda > sda.file
http://www.ivarch.com/programs/quickref/pv.shtml http://www.ivarch.com/programs/quickref/pv.shtml
-B BYTES, --buffer-size BYTES
Use a transfer buffer size of BYTES bytes. A suffix of "k", "m", "g", or
"t" can be added to denote kilobytes (*1024), megabytes, and so on. The
default buffer size is the block size of the input file's filesystem
multiplied by 32 (512kb max), or 400kb if the block size cannot be
determined.
pv is great tool and works really well. On Linux you can even point it at other process ids, and it will automatically scan their open file descriptors and show progress of relevant ones.
- ckuehl 11y agoJust be very careful which direction you point those arrows :-) I've have similar nightmares about typoing `if` and `of` when using dd.
- agumonkey 11y agoQuite often, when I'm about to write a command involving `dd`, the first character I type is #.
- Tiksi 11y agoYou can also drop the `<` in that example, pv takes a file to read from as an argument: pv --buffer-size 1m /dev/sda > sda.file Will do the same thing, and give an accurate % complete progress bar.
- aktau 11y ago> Will do the same thing, and give an accurate % complete progress bar. I'm not sure that's true, last time I tried to do: pv < /dev/zero > /dev/sda To zero a drive, it correctly printed out the total size of the output block device. Perhaps it also does this type of scanning on stdin, if possible. That said, looking at the main page, it appears that this functionality is only available for the output end: Note that if the input size cannot be calculated, and the output is a block device, then the size of the block device will be used and pv will automatically stop at that size as if -S had been given. (http://www.ivarch.com/programs/quickref/pv.shtml http://www.ivarch.com/programs/quickref/pv.shtml)
- Tiksi 11y agoAh, I see what you mean, I was thinking in terms of images/files. As an arguement it gives % of the input (64GB usb drive, 8GB image): > pv /mnt/str/Downloads/stick-8g.img > /dev/sdi 916MiB 0:00:35 [1.88MiB/s] [========> ] 11% ETA 0:04:17 Otherwise it seems to give the size of the output if it's a block device.