(Replying to PARENT post)

This example was performed on the block-special device, so there is no 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...

๐Ÿ‘คNoZebra120vClip๐Ÿ•‘1y๐Ÿ”ผ0๐Ÿ—จ๏ธ0

(Replying to PARENT post)

I've been re-implementing a bunch of coreutils as an exercise, and got stuck on dd input/output block sizes, AND disk/partition block sizes for a while. (As far as I understand it, for dd I need a ring buffer the size of max(ibs, obs), and then some moderately clever book-keeping to know when to trigger the next read/write, perhaps with code specific to ibs>obs, ibs<obs, etc; partitioning on the other hand is plainly stupid, there's decades of hardware and software just lying to each other and nothing makes sense.)

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.

๐Ÿ‘คrollcat๐Ÿ•‘1y๐Ÿ”ผ0๐Ÿ—จ๏ธ0