Guides/Disk won’t eject

Mac won’t eject an external drive? How to find what is using it

Atta 🐬

Founder, Vitals

Published

Quick answer

A disk will not eject while any process has a file or a folder open on it. Quit the apps that used it, close Terminal windows sitting in its folders, and try again. If that fails, run sudo lsof /Volumes/NAME in Terminal to list every process holding it, and quit those. Spotlight and Time Machine let go by themselves, usually within a minute. Force Eject is the last resort, because a file being written can be damaged. Vitals, an activity monitor and process inspector for the Mac, lists every disk with the apps holding files on it, and its Quit Them and Eject quits them and ejects the disk once you confirm.

How to find what is using a disk with Terminal

  1. 01 Open Terminal, in Applications → Utilities.
  2. 02 Type sudo lsof and a space, then drag the disk from Finder into the window to fill in its path, and press Return.
  3. 03 Enter your password. Each line is one open file: the first column is the process, the second its PID, and the last the file.
  4. 04 Quit each app in the list. For a process with no window, run kill <PID> with its PID.
  5. 05 Eject the disk again in Finder, or run diskutil eject with the same path.

If the list is empty and the disk still will not eject, wait a minute and try again: macOS may be finishing a write. mdutil -s with the disk’s path says whether Spotlight indexing is turned on for it.

macOS refuses to eject a disk in use because unmounting it under a program can lose whatever the program was writing. The message in Finder sometimes names the app and often does not. The table below matches the usual holders to what makes each one let go.

What keeps a disk from ejecting

What holds itHow to tellHow to make it let go
An app with a document open The app is in the lsof list, or Finder names it Close the document, or quit the app
A Terminal window A shell such as zsh in the list, with cwd in the FD column Run cd ~ in that window, or close it
Spotlight mds or mds_stores in the list Wait, or add the disk under System Settings → Spotlight → Search Privacy
Time Machine backupd in the list, or a backup under way in the menu bar Let the backup finish, or choose Skip This Backup
Quick Look or Preview QuickLookUIService or Preview in the list Close the preview, or quit Preview
A Photos or Music library on the disk Photos, photolibraryd or Music in the list Quit the app and give its helpers a few seconds
An app that runs from the disk The app’s own path is on the disk Quit the app

What the eject message means

Finder shows one of two messages. “The disk wasn’t ejected because one or more programs may be using it” means some process has something open on the disk, and macOS is not saying which. When it knows the app, the message names it instead. In both, Try Again is safe, and Force Eject unmounts the disk whatever is open.

Is Force Eject safe?

Force Eject unmounts the disk under the programs using it. Files that were only being read are not harmed. A file being written can be left incomplete, and a Photos, Music or Final Cut library that was open can need repair the next time you open it. Use it once you have found the holder and it will not quit, not before.

Ejecting with Disk Utility or diskutil

Disk Utility’s Unmount and Eject follow the same rule as Finder, and fail the same way while something holds the disk. In Terminal, diskutil eject /Volumes/NAME ejects a disk and diskutil unmountDisk force /Volumes/NAME forces it, with the same risk as Force Eject.

When nothing seems to be using it

Log out and back in, which quits every app and helper of yours, then eject. If that works, a background helper was holding the disk. Failing that, shut the Mac down and unplug the disk once it is off: shutting down unmounts every disk safely.

How to stop it happening

Most stuck ejects come from the same few habits.

  • Quit the apps that opened files on the disk before you eject it
  • Keep Terminal windows out of the disk’s folders, or close them first
  • Add the disk to Spotlight’s Search Privacy if you never search it
  • Let a Time Machine backup finish before you unplug its disk

What Vitals adds

Vitals names what is holding a disk, and ejects it for you.

  • Open Files, in the Developer tab: every disk with how many files are open on it, and In Use or Ready to Eject
  • Under a disk, each app and program holding it, with the folder it works in and the files it has open
  • Quit Them and Eject: Vitals names the apps, asks, quits them as ⌘Q does, then ejects the disk
  • Spotlight and Time Machine named for what they are doing, and tried again while they let go

Good to know

  • Vitals does not force eject. If an app will not quit, it says which and leaves the disk mounted.
  • Without Full System Metrics, the files of macOS’s own processes are left out, and Vitals says how many.
  • Open Files is in the window, not in the menu bar dropdown.
Get Vitals for $29 $29 for life during the launch, $49 after, paid once, with a 14-day refund. Or $15 for a year of updates.

Questions people ask

Why does my Mac say the disk wasn’t ejected because one or more programs may be using it?

A process still has a file or a folder open on the disk. It can be an app, a Terminal window, Spotlight or Time Machine. Run sudo lsof /Volumes/NAME to see which.

How do I find out which program is using my external drive on a Mac?

Run sudo lsof /Volumes/NAME in Terminal. Each line is a process and a file it has open on the disk. Vitals shows the same by app, in Open Files.

Is it safe to force eject a disk on a Mac?

Only if nothing is writing to it. Force Eject can leave a file incomplete or a library in need of repair. Find the holder and quit it first.

Can I just unplug the drive?

Not while it is mounted. macOS may still be writing, and the disk can need repair afterwards. Eject it, or shut the Mac down first.

Why is Spotlight using my external drive?

Spotlight indexes a disk so that it can be searched. It finishes by itself. To stop it for good, add the disk under System Settings → Spotlight → Search Privacy.

Is there an app that shows what is keeping a disk from ejecting?

Vitals does. Its Open Files section lists every disk with the apps holding files on it, and Quit Them and Eject quits them and ejects the disk after a confirmation.

In the glossary

More guides