Is there a difference in practice between running blockdev --flushbufs
and sync(1)
on Linux? (apart from blockdev
flushing for a specific device, and sync
being system-wide).
sync(1)
manpage says it flushes file system buffers (only?). If do I/O to a drive (with say, dd
) without going through a file-system layer, is sync
really ineffectual?
When should I use one instead of the other?
Best Answer
This begs the question that writing to a device node bypasses "the file-system layer". I suppose in a sense it obviously does...
In any case, it doesn't matter. If what you are doing does not involve caching, then running
sync
(or some equivalent) anyway wouldn't be "inefficient": if there's nothing to sync, it's a trivial call.I guess when you want to target a particular partition,
blockdev
makes sense. I can't see how it would have any particular advantage oversync
otherwise (and vice versa).