0

For context, I'm on kernel 6.1, so using post-5.7 in-tree exFAT kernel drivers.

Currently, if I plug in an exFAT-formatted flash drive and write to it, it will write to a RAM cache and flush to flash slowly. This is not great because to userspace applications (and therefore the user), it seems like writing has completed, until you try to unmount the drive (or more accurately, the partition) and umount (or udisksctl) hangs. What's worse is if the user is unaware of this behaviour and has the bad habit of not unmounting before unplugging, it just causes silent data corruption.

So I would very much like to disable this caching behaviour. From reading man mount, there's surprisingly no mention of exFAT at all. Under the "Mount options for fat" section, there is the flush option. But if I understand correctly, this section is not applicable to exFAT because exFAT is handled by the exfat driver, which is distinct from the vfat driver which handles the likes of FAT16 and FAT32.

Indeed, if I try to mount my exFAT partition using the flush option, it simply errors:

# sda1 is my exFAT partition
$ udisksctl mount -b /dev/sda1 -o flush
Error mounting /dev/sda1: GDBus.Error:org.freedesktop.UDisks2.Error.OptionNotPermitted: Mount option `flush' is not allowed

So is disabling write cache simply not supported by the exfat drivers currently? If no, are there any workarounds?

5
  • mount -o sync should work Commented Mar 3, 2023 at 8:47
  • @frostschutz I’m not sure the exfat driver supports that :-/ Commented Mar 3, 2023 at 8:58
  • I'm also not sure, but it does use the IS_DIRSYNC macro and mounting it on a ramdisk with sync is slower than without, so it's doing something. That said, it's still a terrible idea to unplug without ejecting properly, and sync may also cause write amplification, and you might still suffer corruption regardless. (My personal impression is that exfat corrupts more easily than fat, anyway... but I don't know about implementation details) Commented Mar 3, 2023 at 9:00
  • @frostschutz right, I wrote that only after checking man mount but that’s not conclusive. Looking at the source code, it definitely honours IS_DIRSYNC for sure (that’s -o dirsync), and I see it checks SB_SYNCHRONOUS and IS_SYNC (-o sync) in a couple of places, so it should be OK. Commented Mar 3, 2023 at 9:09
  • the mount manpage I have does not cover exfat at all yet Commented Mar 3, 2023 at 9:11

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.