by tadfisher · 2y ago · 0 comments
In any case, the tests in ioblksize.h indicate that bs=4M is far too large and may perform worse than the default for cp/cat (128KiB). There is a script there that should clear things up for more modern systems.
The point about fdatasync is superfluous as you can run 'sync' yourself, or unmount the filesystem.
dd uses a default block size of 512 bytes, according to the manual page: calling write(2) directly means you need to choose a buffer of some size.
"bs=" sets both input and output block sizes, which probably isn't the best idea in this case.
Block sizes are a tricky subject:
https://utcc.utoronto.ca/~cks/space/blog/unix/StatfsPeculiar...
https://utcc.utoronto.ca/~cks/space/blog/tech/SSDsAnd4KSecto...
Thank you and everyone else in this thread for the know-how and references! I would like to eventually write an article (or at least heavily commented source) to hopefully explain all this nonsense for other people like me.
("Eject" is macOS's term for "unmount filesystem")