Unlocker / lsof / ps is your friend

So you go about your business using your computer and you want to safely remove or unmount a USB drive or SD card and you get the following message:

Windows: “Problem Ejecting USB Mass Storage Device” The device ‘TheNameOfYourDrive’ cannot be stopped now. Try stopping the device again later
OS X: The disk “TheNameOfYourDrive” is in use and could not be ejected”. Try quitting applications and try again.
eye fi is in used dialog box when unmounting

Windows: the solution is relatively simple: download Unlocker. So when you get the error message just right click > Unlocker > Unlock All
OS X: As the OS X dialog box suggests, you should try quitting applications but you don’t want to just willy-nilly close all applications, just the one causing the problem. To identify the application, open Terminal and type the following:

lsof | grep TheNameOfYourDrive

lsof output

It should display the current usages of the drive. The first name on the left is the application that is using the drive. Close that application and try unmount the drive again and it should work.

I used a similar tip to identify why I couldn’t replace my GIMP installation: I tried copying the application into the Applications directory and just got an error message saying that “The operation cannot be completed because the time libexpat-1.5.2.dylib is in use”. Fired up terminal and instead of “lsof” I used “ps -e” and saw that there processes using it. I killed those processes with “kill -9 processID” (process ID is the leftmost/first column in the “ps -e” output) and was able to copy it without a problem
gimp libexpat 1 5 2 dylib in use ps -e


2 thoughts on “Unlocker / lsof / ps is your friend

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.