News for hackers. Stuff that matters.
Re:Dd is not a disk writing tool (2015) by tacostakohashi on Sunday January 08, 2017 @08:42AM (#13349653)
stat(2) the file, and use the value from the st_blksize member of struct stat.
Re:Dd is not a disk writing tool (2015) by dom0 on Sunday January 08, 2017 @09:22AM (#13349767)
Nononono, that's waaaayy to small. This will be something like 512B or 4K, meaning you'll burn the CPU on syscalls instead of doing meaningful work.

Even the 32K read/write size used by many utilities (shells, XYZsum, rsync and so on) can slow things down with modern/fast IO devices.

Today you'll want to use something like 32K to 2MB. Doesn't really matter around there.

If you're writing synchronously (which you shouldn't), then it becomes a tad more difficult to figure out for optimal performance.

Re:Dd is not a disk writing tool (2015) by snuxoll on Sunday January 08, 2017 @10:43AM (#13350149)
Sync writes have a place, if I'm copying a disk image to a flash drive I typically want to know it's done when dd finishes so I can yank the drive without worrying if the write cache has been flushed.
Re:Dd is not a disk writing tool (2015) by mschuster91 on Sunday January 08, 2017 @10:56AM (#13350229)
At least a couple years ago, it was said one should not rip out USB sticks without ejecting them before, because their controller might do invisible maintenance work and that might lead to data corruption...
Re:Dd is not a disk writing tool (2015) by floatboth on Monday January 09, 2017 @07:38AM (#13355893)
Hmm. Microsoft doesn't agree: https://i.imgur.com/JIZveQz.png

"Disables write caching […] you can disconnect the device safely without [unmounting it]"

Re:Dd is not a disk writing tool (2015) by dom0 on Monday January 09, 2017 @07:59AM (#13356009)
Broadly speaking, flash GC/management journaling is the problem of the controller and is usually not the most broken part of it.
Re:Dd is not a disk writing tool (2015) by floatboth on Monday January 09, 2017 @07:32AM (#13355855)
$ sync; sync; sync

:D