Disable write caching for removable drives

How could I disable write caching for all disks and also only for removable disks without adding each removable disk manually each time?

You can either use udev rules (which might require an entry per device, unless they’re all the same vendor) or use the fstab.

I’d strongly advise against disabling write cache on internal drives; and even for external ones it’s going to noticeably decrease performance.

For example, on Windows 10, if I’m copying a large 6GB+ file to a USB 3.0 stick without write cache, the speeds come to an agonizing crawl. The reason for this is because the stick cannot keep up with the copy operation.


I haven’t a chance to test this out on Linux recently, so I would need to figure out what options to use in the udev rules. However, using the “sync” or “flush” options in an fstab entry will roughly do the same thing, per device.

1 Like

Strange that I haven’t noticed a crawling speed when copying files to a stick in Windows 10, but that could also be because I haven’t used Windows in 2 years now. Setting dirty bytes kinda works in that it gives you the correct transfer speed after a few seconds, but still there’s a delay between the notification saying complete and the process actually having finished.

I still think that KDE should be able to read the real transfer rate and completion status of the data that is being written to the disk instead of the data that is being written to the cache. Surely this isn’t impossible to implement?

That depends on the stick, the USB controller, and the amount / file itself.

I just copied a bunch of files (large total amount) to my exFAT USB 3.0 stick from my NVMe SSD on Windows 10. At first it burst through the door, then it slowed down and was at the mercy of the stick itself permanently writing the data.


sandisk-ultra-usb3-windows10


By the time it finishes, if I go to “Safely Remove” the drive, it will happen instantly. There’s nothing to flush from the cache.

My guess is it only reports what it’s given. Thus, if you disable write cache, KDE will reflect the true speeds / completion of the copy process.

I would have to try and find out. Hoping you could figure out how to disable write cache for removable devices.

You can try a test.

Make a custom “noauto” fstab entry for a USB drive you want to test this on.


UUID=XXXX-YYYY-ZZZZ      /mnt/usb        vfat        rw,noatime,noauto,sync 0 0

Replace the UUID with your partition’s actual UUID. Replace vfat with the actual file-system type. Try out “flush” instead of “sync” if sync is too aggressive for you. (“flush” will wait for the device to be idle, whereas “sync” immediately physically writes the data.)

Make sure the test path, such as /mnt/usb/, exists and is accessible to your non-privileged user.

UUID=02B7-2119      /home/francois/test        exfat        rw,noatime,noauto,sync 0 0

If this is correct how do I reload fstab without rebooting every time?
I tried mount -a but it didn’t work.

mount -av                                                                                                            ✔ 
/boot/efi                : already mounted
/                        : ignored
/home                    : already mounted
/var/cache               : already mounted
/var/log                 : already mounted
/tmp                     : already mounted
/home/francois/test      : ignored

Try to mount it like normal using the tray icon.

The entry for it in your fstab will override the default mount options.

Unfortunately, KDE has a glaring bug in regards to its Disks & Devices widget. It’s supposedly going to be fixed in version 5.23. :confused: So you might have to log out and log back in for it to start working again.


That’s because it’s “noauto” so it doesn’t try to mount it on bootup, since there’s no guarantee the USB drive will be plugged in 24/7.


You can check if it’s using your options after mounting it,

mount | grep /home/francois/test

EDIT: I left out an important detail: you need to specify the uid and gid (user and group) in the mount options, like so,

UUID=02B7-2119   /home/francois/test    exfat    uid=francois,gid=francois,rw,noatime,noauto,sync 0 0
1 Like

Turning off write cache significantly reduces performance. With write cache enabled I got 33s to copy a 339 MB file and 1m58s to copy the same file with write cache disabled.

I would then have to find decent values for dirty bytes. Not the solution I was looking for.

But the moment the transfer is “done”, it’s really done.

Those are some very slow speeds, regardless. Is this an external HDD or a USB stick? Are you using Samsung’s exfatprogs?

You’re not dealing with USB 2.0, right?

Yes it’s USB 2.0 and a USB stick. Guess the only way I’ll kinda get to fix this is by adjusting dirty bytes.
Or KDE could somehow read the actual transfer rate.

I used this command to measure the USB stick performance with write caching disabled and enabled:

time cp "path to file to be copied" "path to mount point" && time sync