When writing content to removable devices on Linux (USB sticks/HDDs, SD cards, etc), I often see incredible write speeds in the first few seconds, sometimes in the order of GB/s (filling of the write buffer) followed by several minutes of quiet (buffer actually being written to the device).
It's misleading. It makes it hard to judge the actual write speed. It's annoying (can't interrupt a program while it's flushing buffers). It can cause FS damage, and at the very least unwritten content when the device is unplugged while it's still being written.
The write buffer appears to be over a GB in my case. Is there a way to control it? I'd like to reduce it to a more sensible value.
Note: This is not about filesystem cache, this effect also appears on raw devices
Note: I do not want to disable write buffers entirely
Thanks!
umount
ing an fs (in GUI use 'eject' button on mounted fs node in the tree shown by file manager). Theumount
effectively completes any pending IO and flushes any outstanding fs cashes. – Serge Jun 25 '16 at 13:21dd
, you must make sure to use something likesync
before you remove the device) – sourcejedi Oct 09 '18 at 09:34