3

I am running a fresh install on Debian 8, and I often have to wait a ridiculous time before my flashdrives get ejected (ranging from 1 to 10.. 15 minutes). During this time, I can't access anything concerning the drive because I get the error An operation is already pending.

It seems like it has nothing to see with the flashdrive format (I've tried FAT, ext4, NTFS), but it also seems to start when I start putting files on them. (nothing heavy though, ~500Mb).

What could be causing this problem? Is there something I can do to speed up ejection?

9

Although I don't know if this is the actual explanation/solution to your question, I believe this is an issue with USB in general.

If you copy large files or many files, the USB device will deliver a message to the host saying "I am about to send you these files". The device will then asynchronously send all files and will take the time it needs to do so. This means that when you do a cp /my/flash/drive/foo.txt /home/bar/foo.txt the device will tell the operating system that files are being copied and then send the files.

The only way I know of to check if all data actually has been transferred is to enter sync after doing a command that copies/moves or deletes files on a flash drive. The sync command will then just block until the drive is finished with transferring data. After that it should be safe to unmount/eject an USB flashdrive.


[EDIT]: Check this post to watch progress of the sync operation: the number printed when you run

watch grep -e Dirty: -e Writeback: /proc/meminfo

should decrease down to zero as background data transfers occur. When it's done, your sync will be completed and your flashdrive will eject.


Another common problem with ejecting USB storage devices is that atleast Debian will not allow it if there is a program, terminal or similar currently working on files/folders on that flash drive. So if you have changed directory to a folder on that flashdrive in a terminal and then try to eject the flash drive using another terminal, it will not allow that until you have changed directory to somewhere else not on the flashdrive in the first terminal.

  • Short answer: It takes a long time because the USB device is still transferring data you have copied, deleted, moved or is working on and refuse to eject the device until it has finished doing the previous command. – Mogget Oct 16 '15 at 10:40
  • Thanks for this explanation! Do you mean that the files might be still transfering even though I am finished with my copying job when I want to eject? Is it a LIE when the progress bar is over after click+drag or I return to command prompt after cp?! ;) – iago-lito Oct 16 '15 at 10:41
  • 1
    Exactly! Just because the command you ran (cp, mv, rm or even a copy paste in Windows) and it finishes, doesn't mean that all the actual data has been transferred. It can still be transferring in the background. – Mogget Oct 16 '15 at 10:45
  • Crazy! So if I understand well, sync is the only reliable way of being sure that all data has been transfered, because it only returns when the work is done.. Side question: then when do cp returns and when do the gui progress bars reach "100%" ? What are they truly waiting for? – iago-lito Oct 16 '15 at 10:51
  • 1
    Look at the first answer in this question; It explains some of the things I did not explain well. askubuntu.com/questions/122113/… – Mogget Oct 16 '15 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.