Summary

Ever tried to eject an external drive, only for macOS to tell you that it’s still in use when you’re absolutely certain that it isn’t? It’s a common and annoying problem, but is fixable. Here’s how I did it.

Use Terminal to See What’s Using the Drive

The error message saying that your drive “wasn’t ejected because one or more programs may be using it” can be confusing.

Normally, if you’ve still got a file open, or you’re copying data to or from the disk, the message will tell you what app is involved. Close the file, wait for the task to finish, and you’re good to go.

Can’t eject drive warning in macOS.

But sometimes, there doesn’t appear to be any app using the drive, yet even the “Try Again” and “Force Eject” options won’t work. This likely means that there’s some background task still running. The only way to find out what it is is through a terminal command.

Open Terminal (press Command+Spacebar and type “Terminal”) and type in the following command, leaving a space at the end.

Dragging the drive into Terminal.

Then drag your drive icon into the Terminal window to add the full path to it, so that it looks like this:

Hit Enter, and type in your password if prompted.

The process using the drive.

The resulting output will list all the apps that are using the drive in the column labeled “Command.” If you recognize the culprit, you might be able to shut down the app orgo into Activity Monitor and quit the relevant process. In my case, and what seems like the most common issue, the process “mds” was accessing the disk’s contents.

“mds” stands for Metadata Server, and means that Spotlight is indexing the drive’s files. To begin with, you’re able to try and wait for it to finish, although in my experience that might never happen. If it doesn’t, you can remove the drive from Spotlight altogether.

Drag the drive to exclude it from Spotlight.

Remove the Drive From Spotlight Indexing

Spotlight is a Mac search toolyou can access by pressing Command+Spacebar on your keyboard. Among other things, it indexes all the files and folders on your external drives so you can easily access them. But sometimes this can cause problems. I had two flash drives and an external SSD that I couldn’t eject, and Spotlight was the reason in all cases.

The solution is to remove the drive from Spotlight indexing. The downside to this is it means you won’t be able to search quickly for files on your external device. On the other hand, it does mean you’ll be able to eject it properly.

Disk Utility in macOS.

Go to System Settings > Spotlight and scroll down to click the “Search Privacy” button. Drag your external drive into the window that opens and click “Done.” This will prevent Spotlight from indexing the drive.

Now, you should be able to eject your drive as normal.

If you can’t drag the external disk into the search privacy window, it might mean that Spotlight has already begun indexing it. If this happens, log out of your Mac, remove the drive, log back in, reattach the drive, and then try again. It should work this time and fix the problem.

Repair the Drive

The final step is torepair your external drive, just to ensure that there aren’t any hardware issues. You have to do this part last because the repair process involves ejecting the volume, which it won’t be able to if you haven’t fixed it.

Open Spotlight by pressing Command+Spacebar and start typing “Disk Utility.” Select it from the list when it pops up.

Under “External” in the sidebar, select the Volume for your external drive (not the drive itself) and go to First Aid > Run. Disk Utility will eject and scan it, then repair it if necessary.

It’ll also flag up any warnings that could be a sign of any hardware problems. If you see something here, it’s time to consider replacing the drive so you don’t get hit by hardware failure in the future.

With all the steps complete, you should now be able to eject the disk without any problems. Repeat these steps for any subsequent drives that you may’t eject.

There are lots of generic tips for removing drives that macOS can’t eject. These might include force-quitting Finder, logging out of your user account, shutting the lid on your MacBook, or even just yanking it out anddealing with “Disk Not Ejected Properly” warning.

Unless you’re writing to the drive at the time, your data is unlikely to get corrupted. But it’s still preferable to fix the problem, and these steps should help you do that.