Disabeling USB file transfer cachce

Hi

I have been using linux for a little over a year now, and i have almost made the switch completely from Windows. I have had one major issue that almost made me switch back however.

I don’t use cloud services, i use an encrypted USB drive to store my data that i carry around. It works well, except for the file caching that linux does. It has let to some file corruption over the year and IMO it’s pretty unreliable especially when it comes to bigger files.

I discovered that it was quite easy to disable on Debian systems by editing the /etc/hdparm.conf file. This file is empty or not existing on openSUSE, so i was wondering if anyone knew of an easy way of disabling it on openSUSE across the system.

Leap is my preferred system, and i prefer to stay there if it’s possible for me.

I hope someone can help.

It is rather unclear, what caching you are talking about.

it sounds like you mean filesystem page cache, but then suddenly

… you talk about hrparm which has nothing to do with page cache. hdparm may disable internal HDD caching. This needs ability to send ATA commands to the HDD which may not be possible with USB connected drives (it is up to the manufacturer of te USB-ATA bridge).

What is “it” in the sentence above? If it refers to “this file” then “this file” does not exist and so is ultimately disabled :slight_smile:

Jokes aside - you need to be more specific what your problem is. If you believe that that hdparm does solve your issue - you can simply use udev rule and hdparm script from Debian. Or simplify it by calling hdparm with needed parameters directly from udev rule.

If it is Linux caching - you can try mounting with sync option which should eliminate any caching performed by Linux.

the udev rule?

In terms of the sync thing, i would rather have something that works across the system, and not just on one USB drive.

The issue im having is that the file transfer display will disappear long before the the files are actually transferred to the device. I would like to have it function the way it does on Ubuntu.

in hdparm i can just remove the comment from write_cache, and that seems to give the expected behavior im looking for.

If this was a question, you forgot to spell it out. I am bad at mind reading.

Guess what - hdparm.conf is interpreted by a script that is called from within udev rule. I do not understand where “just one USB drive” comes from.

And that is exactly what always happened to me on Ubuntu 22.04.

“I want it like another distribution does it” rarely leads to solution. Users on these forums are unlikely to know implementation details of another distribution. Find out what Ubuntu does, then we can think about how to do the same on openSUSE.

But quickly testing on Ubuntu 22.04 with GNOME desktop - USB FAT stick is mounted with flush option, which is somewhere in between of dirsync and sync. Which may explain why it looks better. Check mount options on openSUSE.

So why do not you test first whether setting whatever parameters you think are necessary solves your problem on openSUSE? You do not need /etc/hdparm.conf to use hdparm.

I have no idea what any of this means. sorry.

Thanks for your time anyway.

Are you safely removing the USB???

Yes. The issue is that i have no understanding of how long i have to wait when the file dialog disappears.

When i guess and try and safely remove the USB, then it would tell me that it’s busy - that’s fine. The issue is that sometimes the message and the USB in the file manager will disappear, and to me that looks likes it’s finished and most of the times it has.

I do think however that it has lead to file corruptions two times over a year, something i have never experienced before moving to linux.

Gnome first notifies me the USB device is being unmounted and then later when it’s safe to remove.
But I don’t really trust it all that much so I run sudo sync just to be sure before unmounting.

what is sudo sync supposed to do? my terminal windows seems to do nothing when i use the command?

At a terminal, execute “man sync” to read the manual page for sync :+1:

It is admittedly very irritating to copy files, have them “complete” and then be unable to unmount the device for another few minutes. As a default… it just doesn’t seem ideal.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.