4 ms·
every command listed in this article is bad. # Cat version with progress meter cat image.iso | pv >/dev/sdb The progress meter here is mostly meaningl
by Retr0id 4y ago
every command listed in this article is bad.
# Cat version with progress meter
cat image.iso | pv >/dev/sdb
The progress meter here is mostly meaningless. You'll see the initial progress go very quickly (because you're writing to in-memory cache), and once it's "done", you'll have to wait some amount of additional time for a final `sync` to complete (and if you forget to do that, you might remove the drive while writes are still in progress).
The best way to write an image to a drive is like so:
dd if=foo.iso of=/dev/sdx bs=4M oflag=dsync status=progress
`oflag=dsync` bypasses the write cache, so your progress bar is actually meaningful. It also guarantees that writes are actually completed[1]. Yes, that 4M block size may be improved by manual tweaking, and it would be nice if that happened automatically. I'm sure tools to do this exist, but they're not installed ubiquitously by default. Older versions of dd do not support `status=progress`, and as a workaround you can do:
pv foo.iso | dd of=/dev/sdx bs=4M oflag=dsync
(alternatively, you can set up a bash for-loop that periodically sends SIGUSR1 to dd)
[1] Unless the drive has onboard dram cache etc., but this is rare for removable media
P.S. If you use "/dev/sdx" in example commands, it will fail when someone blindly copy-pastes without reading anything, instead of erasing their whole OS
- deleted 4y ago[deleted]
- ptman 4y agoI've started to do this as well. BSD has SIGINFO (^t) for dd status, but unfortunately linux lacks that
- cestith 4y agoGNU dd uses SIGUSR1 on Linux. Yes, it's unfortunate for people who move back and forth between them, especially when newer to one or both.
- MisterTea 4y agoI use pv directly to write files to devices using pv <image.iso >/dev/sdb
- Retr0id 4y ago> The progress meter here is mostly meaningless. You'll see the initial progress go very quickly (because you're writing to in-memory cache), and once it's "done", you'll have to wait some amount of additional time for a final `sync` to complete (and if you forget to do that, you might remove the drive while writes are still in progress).