# macOS: diskutil: Unmount of disk2s1 failed: at least one volume could not be unmounted / The disk wasn't ejected because one or more programs may be using it

**Code:** `Volume failed to unmount / disk not ejected because in use` · **Category:** macOS · **Seen on:** macOS

macOS can't eject a drive because a process still has files open on it.

## Meaning

Find the process: `lsof +D /Volumes/NAME` (or "Force Eject" in the Finder dialog, which risks data loss). Close apps, Spotlight indexing (`mdutil -i off`) and terminals sitting in the volume. Then `diskutil unmount force /Volumes/NAME` or `diskutil eject`.

## Common causes

- App or terminal using files on the volume
- Spotlight/Time Machine indexing it
- Photos/Music library on the drive
- Backup or antivirus scanning
- Stuck process after a crash

## Quick fix

1. `lsof +D /Volumes/NAME` and quit the listed apps
2. `diskutil unmount force /Volumes/NAME`
3. `diskutil eject /dev/diskN` once unmounted

## Detailed fix by platform

### macOS

1. `diskutil list` and `lsof +D /Volumes/NAME`

## How to diagnose

1. **Process** — lsof output?
2. **Index** — Spotlight?
3. **Force** — Data safe?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/macos/diskutil-unmount-failed-in-use)
