Why can't I eject my external disk because it is in use on macOS?

A terminal-first walkthrough to find what is holding your external disk open on macOS and eject it safely, from quitting apps to forcing an unmount.

macOSProcessesTerminalstoragediskDiagnosticsdiskutilMedium risk
Identify the volume with diskutil info, quit the app holding it open, then run diskutil unmount on the volume.

What this covers

macOS refuses to eject a disk the moment any process still has files open on it. This guide walks you through identifying the disk, releasing whatever holds it, and ejecting safely from the Terminal — no data loss, no yanking the cable.

Symptom

?Finder shows "The disk 'MyUSB' wasn't ejected because one or more programs may be using it", or clicking Eject does nothing and the volume stays on the desktop.

Identify the disk and its mount point

Before ejecting, confirm exactly which disk is refusing to go. Listing all connected disks shows the device node (like disk2s1) and the /Volumes name macOS is using. If the volume appears here but Finder says it is "in use", you know the problem is a process holding it open, not a hardware fault.

See every internal and external disk, its partitions, and its /Volumes name from the terminal with one command.

Command
$ diskutil list

Check the volume's mount state and device node

Inspecting the volume tells you whether it is currently mounted, which device node it sits on, and its filesystem. Note the device identifier — you will need it if unmounting fails and you have to force the eject later. If the info shows the volume as mounted, the eject problem is software-side.

Get the device node, filesystem, SMART health, and APFS role of any volume from one command.

Command
$ diskutil info /Volumes/Macintosh\ HD

Quit an app that may be holding files open

The most common cause of "disk in use" is an app with a document or cache open on that volume — a hung app keeps the handle forever. Quitting the app by name releases the handle. If the disk was in use by a video editor, download manager, or a frozen app, ejecting works immediately afterwards. Relaunch the app afterwards if you still need it.

macOSQuit or Restart a Frozen App with killallMedium riskStep 3Optional

Force-quit a hung macOS application by name from the terminal using killall, then relaunch it in one more command.

Command
$ killall Safari
▾ Undo
Undo
$ open -a Safari

Stop Spotlight indexing the volume

Spotlight's indexer (mds and mdworker) constantly scans newly mounted drives and can keep a volume busy long after you last used it. Turning off indexing for that volume frees it. You can turn indexing back on later if you want to search that drive from Finder.

Save CPU and disk churn on drives you never search from Finder.

Command
$ sudo mdutil -i off /Volumes/工作盘
▾ Undo
Undo
$ sudo mdutil -i on /Volumes/工作盘

Try a clean unmount first

diskutil unmount detaches the volume without powering the drive down — it is gentler than eject and usually succeeds once the blocking process is gone. If it succeeds, the drive may still be physically connected but the volume is safe. If it reports the volume is in use, move on to a full eject.

Re-attach a stubborn external volume or detach one without ejecting, using diskutil's mount and unmount verbs.

Command
$ diskutil mount /Volumes/MyUSB
▾ Undo
Undo
$ diskutil unmount /Volumes/MyUSB

Force the eject from the Terminal

If Finder keeps refusing, eject the whole disk from the command line. diskutil eject flushes buffers and detaches the disk — the terminal equivalent of Finder's Eject, but it works even when the Finder dialog is stuck. Target the whole device (disk2) rather than a single slice if the whole drive should disconnect.

macOSEject a Drive with diskutil ejectMedium riskStep 6

diskutil eject flushes buffers and detaches a disk or volume — the terminal version of Finder's Eject.

Command
$ diskutil eject /Volumes/MyUSB

Fall back to hdiutil detach

If diskutil still reports the disk as busy, hdiutil detach is the lower-level tool that works for external drives and mounted disk images alike. It often succeeds where diskutil gives up, especially when the volume was mounted by a disk image rather than a plain external drive.

Unmount and eject external drives and disk images from the command line.

Command
$ hdiutil detach "/Volumes/MyUSB"

Eject everything ejectable as a final sweep

If you have several volumes and are unsure which one is stuck, this one command asks Finder to eject every ejectable disk at once. Any volume that disappears from the desktop was successfully ejected; whatever remains is the one still being held open — go back and quit the responsible app.

macOSEject all external disks at once on MacLow riskStep 8Optional

Safely unmount every ejectable volume — USB drives, SD cards, DMGs — in one step.

Command
$ osascript -e 'tell application "Finder" to eject (every disk whose ejectable is true)'
!Force-ejecting while data is being written can corrupt files. Quit the writing process first, and only use forced unmounts as a last resort.

How to confirm it worked

The volume disappears from the desktop and from diskutil's output, and the mount point no longer exists under /Volumes.

Undo everything

Every command above can be reverted. Run these in order to undo all of it.

Undo everything
$ diskutil unmount /Volumes/MyUSB
sudo mdutil -i on /Volumes/工作盘
open -a Safari

Review before running — some steps may not be independent.

Sources

  • DISKUTIL(8) - macOS manual page
    Apple (Xcode man pages mirror) · vendor-doc · 2026-09-17
    Evidence: The manual page text contains 'diskutil list' describing it as listing disks with their partitions and identifiers such as disk0s1.
  • diskutil - Modify, verify and repair local disks
    SS64 · technical · 2026-09-17
    Evidence: Documents the diskutil command with 'list' as its first documented verb for listing disks, including the 'diskutil list' syntax shown on the page.
  • macOS osascript command reference
    SS64 · technical · 2026-09-16
    Evidence: osascript runs AppleScript from the Terminal; Finder's eject command safely unmounts every ejectable disk.
  • About Files and Directories
    Apple Developer · vendor-doc · 2026-09-17
    Evidence: Apple's file-system programming guide covering volumes, mount points, and macOS storage layout.
  • killall - kill processes by name
    SS64 · technical · 2026-09-17
    Evidence: Documents killall for terminating processes by name, including sudo usage for other users' processes.
  • Quit an app on Mac
    Apple · vendor-doc · 2026-09-17
    Evidence: Apple's guidance on quitting unresponsive apps, confirming the everyday need killall addresses from the command line.
  • mdutil – Manage Spotlight indexes
    ss64.com · technical · 2026-09-17
    Evidence: Documents -i on/off, -E erase, and per-volume status
  • hdiutil – Create and manipulate disk images
    ss64.com · technical · 2026-09-17
    Evidence: hdiutil detach unmounts and ejects a volume identified by its mount point or device node.

Last verified: 2026-09-21

Related guides