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.
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
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.
$ diskutil listCheck 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.
$ diskutil info /Volumes/Macintosh\ HDQuit 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.
Force-quit a hung macOS application by name from the terminal using killall, then relaunch it in one more command.
$ killall Safari▾ Undo
$ open -a SafariStop 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.
$ sudo mdutil -i off /Volumes/工作盘▾ 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.
$ diskutil mount /Volumes/MyUSB▾ Undo
$ diskutil unmount /Volumes/MyUSBForce 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.
diskutil eject flushes buffers and detaches a disk or volume — the terminal version of Finder's Eject.
$ diskutil eject /Volumes/MyUSBFall 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.
$ 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.
Safely unmount every ejectable volume — USB drives, SD cards, DMGs — in one step.
$ osascript -e 'tell application "Finder" to eject (every disk whose ejectable is true)'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.
$ diskutil unmount /Volumes/MyUSB
sudo mdutil -i on /Volumes/工作盘
open -a SafariReview before running — some steps may not be independent.
Sources
- DISKUTIL(8) - macOS manual pageEvidence: 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 disksEvidence: 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 referenceEvidence: osascript runs AppleScript from the Terminal; Finder's eject command safely unmounts every ejectable disk.
- About Files and DirectoriesEvidence: Apple's file-system programming guide covering volumes, mount points, and macOS storage layout.
- killall - kill processes by nameEvidence: Documents killall for terminating processes by name, including sudo usage for other users' processes.
- Quit an app on MacEvidence: Apple's guidance on quitting unresponsive apps, confirming the everyday need killall addresses from the command line.
- mdutil – Manage Spotlight indexesEvidence: Documents -i on/off, -E erase, and per-volume status
- hdiutil – Create and manipulate disk imagesEvidence: hdiutil detach unmounts and ejects a volume identified by its mount point or device node.
Last verified: 2026-09-21
Related guides
Find out whether your Mac's disk is healthy: check SMART status, rule out a full disk, verify the filesystem, and repair errors from the terminal.
Find out why Spotlight returns no results — disabled indexing or a corrupted index — and rebuild it from the terminal.
Diagnose a stubborn Bluetooth device with system_profiler, then power-cycle Bluetooth and restart bluetoothd to get it connected again.