24

I have a question about ejecting USB flash drives in Ubuntu Xenial 16.04.

When there is still some I/O going on upon clicking the eject button, I get the message:

Writing data to (...). Don't unplug until finished.

I get the message, but what is unclear to me: How will I get notified when the writing is finished? This message seems to stick around until it is dismissed. There is no additional message that notifies me I can unplug the drive.

And it is not possible to click "eject" again to check the status, because the drive has already disappeared in the explorer.

How is the user supposed to know when the drive can be ejected? Is there a terminal command I can use? More importantly, this seems like a shortcoming of the UI.

Yaron
  • 12,828
  • 7
  • 42
  • 55
Sander Vocke
  • 343
  • 2
  • 5
  • 1
    i'm wondering about the same thing. it seems to be the same issue in 17.10 as 16.04. you write some random, well-chunked data to a disk (say 300 MB) and the transfer dialogue closes MUCH sooner than the system allows you to unplug. in my opinion using a sandisk 3.0 the system is getting congested on something because windows would eject the same operation comparatively sooner. sometimes linux completely hangs for hours and i have to go to the disk utilty and power it off or reboot the computer to avoid corrupt sectors. not ideal. it also has bugs where it will give you a ridiculous transfer ra – gamesguru Dec 08 '17 at 22:12
  • this is incredibly annoying. Its the one thing windows gets right – Robin Oct 17 '21 at 21:11
  • 1
    Good news, in 19.10 after it's "done" it pops up a dialog "can be ejected" :) – rogerdpack Dec 25 '21 at 21:38
  • 1
    @rogerdpack Same thing happened to me in 18.04. It prompts me with 'can be ejected'. It literally popped up as soon as this page loaded. :) – Missing User Jul 17 '22 at 02:06

2 Answers2

12

I have had this in the past and found a solution that works for me.

The command sync will ensure everything is written to all attached disks.

You should not need sudo sync for this unless the disk has some log files owned by root for example that also need writing.

If the sync command ends with no errors I've found it is safe to remove the drive.

Noki
  • 912
  • 2
  • 16
  • 33
  • 1
    This fixed the issue of an "endless spinning wheel" next to the USB memory stick after I triggered the eject. Running `sync` made the wheel disappear and allowed to eject again. The 2nd attempt quickly finished and made the memory stick disappear so that I could safely remove it. – Lars Blumberg Apr 07 '22 at 13:02
3

If the drive is already disappeared in the explorer it means it is already unmounted. Then you are safe to extract the drive whenever you want. If the warning message is still hanging around then that is a (minor) bug. Just forget it. If you want to double check, open a terminal and type "df -h" to see if it is still mounted. If I'm right it should not.

ciampix
  • 473
  • 3
  • 11
  • Evidently not true under [Ubuntu 16](https://ubuntu-mate.community/t/safe-to-remove-usb-device/17811), but fixed under Ubuntu 18. Just got bitten by this today. I run Fedora at home & never even suspected there would be a problem. – ulatekh Mar 01 '21 at 21:09
  • 2
    Oh I see, thanks to point me to that link ... I did not know that in U16.04 there was such a HUGE and dangerous bug! How others have already said, doing a couple of "sync" is always a good idea before unmounting anyway... – ciampix Mar 02 '21 at 22:22