Unplugging usb safely takes a long time or does not work, safely unplug it via terminal?

Hi friends.

I just formatted my USB flash with the latest version of Ventoy, and inside I put the latest EOS ISO. The file was copied and finalized successfully.

From Dolphin, I right clicked on my usb flash => unmount safely unplug. The problem is that it remains loading for a long time, or sometimes forever.

It happens to me with external hard drives too, so I don’t know what the problem is.

I don’t like to unplug USB flash or external hard drives until the hard drive has been properly removed. Since I’m afraid that the files will be corrupted or something like that.

Normally, when this happens, I reboot EOS with the USB connected, as I figure it’s better than forcibly unplugging it.

I’m wondering if maybe the correct way to unplug USB flash and hard drives is through the terminal or something? Maybe since Dolphin it doesn’t work well. I’m on X11/Xorg by the way, and all my usb flash and hard drives are ETX4.

Thanks in advance.

image
image

The graphical write to the external is always faster than the actual drive write. A lot of times if you look at the device you can see the light working. Nothing is going to make the drive write any faster than its meant to. (ie plugging a USB 2 into a USB 3 will not make the write faster on the USB 2 device)

I suggest you use a bit more patience and allow the system to do the job you set it out to do.

3 Likes

The GUI shows “writing complete” long before the actual data is written due to “caching”. To “prevent” caching, removable drives should be mounted with the “sync” mount option. It isn’t always so when you mount via the GUI. So, if you want to ensure that the data gets written when the GUI says so, mount the drive manually in the terminal (or “remount” it manually with the “sync” option added).
And just for completeness: “safely remove” in the terminal is just “umount”. To be even safer, invoke “sync” 3-4 times before “umount”.

3 Likes

Omg, I didn’t know this! That is, when the GUI says “copy finished”, it is actually still copying.

Is this something normal, or perhaps a KDE or DOLPHIN bug that they will fix in the future?

I would really like to know when I can remove my hard drive without breaking files.

My USB flash doesn’t have lights, but my external hard drive does, and I made important backups there and I always had this problem. So I’ll be more careful next time, because I thought it was stuck, and I unplugged it after waiting for a while. I trusted the GUI too much…

Oh, I didn’t really know this, I’m a noob and I didn’t think there were these kinds of problems with the GUI, I guess that’s why everyone uses the terminal…

I’m very sorry, I don’t want to take advantage of your knowledge but, from ignorance:

Is it advisable to disable the “cache”? This doesn’t negatively affect the files when copying them, right?

So if I mount the drive from the terminal, the GUI will work correctly, so theoretically I just have to mount and unmount it from the terminal, and then I won’t have this problem anymore.

Could you give me a guide to use the mount + sync command from the terminal?

After mounting from the terminal, I plan to use the GUI to copy and paste with right click to my hard drive.

And then, synchronize several times as you recommended + unmount, from the terminal.

(By the way, what’s the point of synchronizing? so that the terminal and the GUI are synchronized at the same time?)

Thanks again to both of you, friends, I have had this problem forever and I thought that my hard drives were not compatible with Linux or the Linux Kernel or something like that.

No, it’s for synchronizing the cache and the actual disk data. I guess that “safely remove” actually calls “sync” for that drive behind the curtains.

In my super-humble opinion, it is advisable to “disable” caches only for removable drives.

GUIs are more discoverable if done right, CLIs are more precise.

1 Like

It is normal.

If you safely eject the removable device, it won’t tell you it is safe to remove until it is ready

Some people do disable it because they prefer a certain behavior and prefer that. In my opinion, it is better to keep the cache. It stops the writing application from being blocked on the device.

2 Likes

I took a further look on my own system, and it’s actually pretty easy to configure KDE (udisks2, in fact) to mount removable drives with “sync”. Just search for “udisks2 mount options”.

I put nothing into the remove drive safly feature of ANY OS, I have never had anyone issuse just unplugging the USB divice. No brackage of the device, no accidental wiping of the device, nothing. That said when copying to or from any USB drive including flash drives once I’m told moving / copying is done I wait an additional 10 minutes before unplugging it.

Have you tried the sync command on the terminal?
(This was already mentioned above.)
Run it after starting the big copy. It should wait until all cache stuff has been written to all disks, so that should help you see when the big copy is ready.

See also: man sync

1 Like