# Disable USB/Flash write cache (FS independent)

## erpalma

How can I disable write cache on usb/sd drives? Hdparm won't do that and mounting with sync,dirsync is not a good solution (incredibly slow). I hate having no real throughput measure in kde file copy.

----------

## eccerr0r

I see this question a lot, but it's somewhat misleading of a question --

The reason why mounting sync is so slow is that out of order caching is disabled, which gives a huge benefit to system responsiveness.  Caching writes is a good thing on multiple levels for all kinds of disks, we don't want to remove caching, even write caching.

Really what's needed is probably hack the copy code to include fsync() before it closes the destination file descriptor.  If this doesn't make sense, probably this should be an idea that's brought to the upstream (KDE) developers.  Unfortunately this involves code hacking, but since we have source code...

Doing a google on this looks like this may have been removed to reduce spinups for other people who copy from/to the same disk and save power... so I guess this may be a case-by-case issue whether to fsync or not... ugh... no clear answer here, computer would never know if you want to or not want to fsync...

----------

## erpalma

You are right, I think it's a good solution. But why on kubuntu (for example) copy progress bar does work? Did they hacked kde code as you suggested?

----------

## i92guboj

As said, there's no way around slowness. The device will be as fast as the hardware and the driver allow. Disabling asynchronous write support will show you the real time needed to copy a file. The KDE issue is different. But in all my life I haven't ever seen a progress bar that is useful for anything at all anyway (your mileage may vary).

Bear in mind that mounting with the sync option has some implications though. It will effectively render your I/O scheduler useless, since write operations will not be scheduled and reordered in the sanest possible way, they will be just dispatched as soon as possible instead. That can potentially shorten the life of NAND flash based devices. Some programs might lock and turn completely zombie until the write operations have ended as well, that should be fixable at source level.

The real question is why do you want to do so. You always risk breaking an fs if you don't unmount it before unplugging. Some of them will be marked as dirty causing some annoying side effects. And when you unmount an fs, sync() is run so you shouldn't be needing -osync at all at mount time.

----------

