Eject disk

So the problem is that you want to eject a disk/DMG/mount on your Mac and it says it is still in use “The disk “x” is in use and could not be ejected.”. Here is the solution using your command line (Terminal.app) to be able to safely eject the mount.

lsof +D /Volumes/{VolumeName}/

This will give you some results like:

COMMAND   PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
HoggingApp 69668 myuser  txt    REG   14,5  3791772   27 /Volumes/{VolumeName}/App.app/Contents/MacOS/App

Hopefully you will recognise the application that is using that resource (in this example HoggingApp). If you can close this application you should be able to eject your mount now.

If closing the application did not work for some reason you could try the following command using the PID found from the above result(s)

kill 69668

Or If running a kill has a permissions based issue just add ‘sudo‘ to the beginning of the line (assuming you have sudo access).