3

I recently got a new mac and simultaneously upgraded from Mojave to Monterey.

Formerly, when I ran diskutil unmountDisk <disk here>, if there was a dissenting process, it would provide me with the PID of the dissenter, e.g.,

$ diskutil unmountDisk disk4
Unmount of disk4 failed: at least one volume could not be unmounted
Unmount was dissented by PID 293

But now this useful information seems to be nowhere to be found, i.e., the result of the above command is now simply

$ diskutil unmountDisk disk4
Unmount of disk4 failed: at least one volume could not be unmounted

I'm wondering if there is still any way to recover the PID of the dissenting process(es) programmatically, whether through diskutil or some other tool. Thanks!

1 Answer 1

1

You can use the lsof command in the Terminal to see which processes have which files open. For example for your disk4:

lsof /dev/disk4

or if you have multiple volumes on that disk mounted:

lsof /dev/disk4*

or you can use a mount point like this:

lsof /Volumes/MyDisk

You'll get a list of open files along with the PID of the process that holds the file open. These are the processes that keeps you from unmounting the file systems.

2
  • Thanks! On my machine, lsof /dev/disk4 prints nothing, I need to specify the partition like /dev/disk4s2, or the mount point /Volumes/MyDisk. Since there may be multiple partitions, most convenient seems to be to use a glob, e.g., lsof /dev/disk4*
    – msailor
    Dec 5, 2021 at 12:11
  • run the lsof with sudo -- for me, without sudo, it prints nothing.
    – Lou Franco
    Jun 9, 2022 at 19:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .