Eject a Drive with diskutil eject

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

macOSvolumesdiskdiskutilMedium risk
Run `diskutil eject /Volumes/MyUSB` (or the /dev/diskN identifier) to unmount and power down the drive.

01Command

Command
$ diskutil eject /Volumes/MyUSB

02What it does

Ejecting unmounts every volume on the disk and tells the enclosure to spin down, so pulling the cable afterward is safe. diskutil accepts either the mount point or the device name; use the identifier from `diskutil list` to eject everything at once. If eject fails, some process still holds files open — `lsof +D /Volumes/MyUSB` names the culprit, and Finder's error is often just Spotlight or a Finder preview window. Replug or run `diskutil mountDisk` to bring it back.

03Risk

RiskMedium risk
RequirementsClosing apps using the volume, or `lsof +D /Volumes/MyUSB` to find them, fixes 'eject failed' errors.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-09-18 · Category: System & Settings

06Related solutions