Eject a Drive with diskutil eject
diskutil eject flushes buffers and detaches a disk or volume — the terminal version of Finder's Eject.
Run `diskutil eject /Volumes/MyUSB` (or the /dev/diskN identifier) to unmount and power down the drive.
01Command
Command
$ diskutil eject /Volumes/MyUSB02What 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
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- diskutil — disk utility tool (macOS man page)Evidence: Documents diskutil eject <device|mount point>, which flushes and detaches the whole disk safely.
Last verified: 2026-09-18 · Category: System & Settings