MacOS external drive unmount woes

Sometimes MacOS refuses to unmount an external drive. I find this is often the case if I’ve been transfering and/or processing large audio files of many GB in size. More often than not this is because some background MacOS process is still holding the file in memory, or referencing the file in some way.

I’ve found that these steps in a terminal often solve the issue:

  1. Find the blocking process
    lsof +D /Volumes/YourDriveName
    Note the process name and PID from the output.
  2. Kill the process
    kill -9 <PID>
    Common culprits are QuickLook (QuickLook) and Spotlight (mds/mdworker). Using -9 (SIGKILL) bypasses the process’s ability to ignore the signal.
  3. Find your disk identifier
    diskutil list
    Look for your drive by size — it will appear as disk2, disk3, etc.
  4. Unmount the disk
    diskutil unmountDisk /dev/diskN
    Replace diskN with the identifier found above.