this post was submitted on 25 Aug 2023
196 points (99.0% liked)

Linux

47237 readers
3343 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

I start: the most important thing is not the desktop, it's the package manager.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 15 points 1 year ago (2 children)

Unmounting removable drives after writing to then is crucially more important than on Windows

[–] [email protected] 5 points 1 year ago (1 children)

It's pretty important on Windows too, though. Always “eject” or “safely remove hardware” before unplugging!

[–] [email protected] 2 points 1 year ago (1 children)

Not in Windows 10/11. You can still "eject" if it makes you feel better, but it's basically redundant. They reworked the support for removable media so they are always ready to remove except during active read/write operations.

[–] [email protected] 9 points 1 year ago* (last edited 1 year ago)

Read/write operations can happen in the background at any moment as long as the drive is mounted, so that's not terribly comforting.

Anyway, Windows has always avoided deferring writes on removable media, for as long as it's been capable of deferring writes at all. That's not new in Windows 10.

Linux has a mount option, sync, to do the same thing. Dunno if any desktop environments actually use it, but they could. Besides being slower, though, it has the downside of causing more write operations (since they can't be batched together into fewer, larger writes), so flash drives will wear out faster. I imagine Windows' behavior has the same problem, although with Windows users accustomed to pulling out their drives without unmounting, I suppose that's the lesser of two evils.

[–] [email protected] 1 points 1 year ago (1 children)
[–] [email protected] 3 points 1 year ago (5 children)

On Windows, I often simply took out the USB drive without "safely removing" it. The data was there 99% of the time. On Linux, if I'm not mistaken, unmounting the drive before disconnecting is what actually writes data to it.

[–] [email protected] 10 points 1 year ago

I don't think Linux literally waits for you to unmount the drive before it decides to write to it. It looks like that because the buffering is completely hidden from the user.

For example say you want to transfer a few GB from your SSD to a slow USB drive. Let's say:

  • it takes about half a minute to read the data from the SSD
  • it takes ten minutes to write it to the USB
  • the data fits in the spare room you have in RAM at the moment

In this scenario, the kernel will take half a minute to read the data into the RAM and then report that the file transfer is complete. Whatever program is being used will also report to the user that the transfer is complete. The kernel should have already started writing to the drive as soon as the data started being read into the RAM, so it should take another nine and a half minutes to complete the transfer in the background.

So if you unmount at that point, you will have to wait nine and a half minutes. But if you leave it running and try to unmount ten minutes later it should be close to instant. That's because the kernel kept on writing in the background and was not waiting for you to unmount the drive in order to commit the writes.

I'm not sure but I think on Windows the file manager is aware of the buffering so this doesn't happen, at least not for so long. But I think you can still end up with corrupted files if you don't safely remove it.

[–] [email protected] 5 points 1 year ago

That can be configured with the sync option of mount.

[–] [email protected] 4 points 1 year ago

Or just sync before pulling it.

[–] [email protected] 1 points 1 year ago

Really? I've literally never done this but I suppose I really only use my USB for dd'ing a distro.

[–] [email protected] -1 points 1 year ago (1 children)

I do not think this is the case. You can disable on GNOME Disks active disk write caching for removable storages, exactly the same way as on Windows.

Also, Thunar File Manager has an option to partially write files when copying/moving and when moving, only remove the file from source directory when the copy is successful. I find it remarkable against data corruption for large file transfers.

[–] [email protected] 1 points 1 year ago (1 children)

Yeah, but you just describe 2 features on specific apps that don't need to be enabled by default.

[–] [email protected] -1 points 1 year ago

I mean, even the SATA over UAS is a pain with Linux, since the new implementation sacrifices SMART data for faster RW speeds on Linux, and you have to fallback manually on the old driver to read SMART data on external HDDs. On Windows, you just use CrystalDiskMark and it works.

Linux needs you to do a little work here and there for such things. I do not really eject everything safely on Linux. The feature on Thunar is handy.