MacOS – New “Resource busy” error when trying to mount DMG files

macos

I am having a new issue where DMG files sometimes fail to mount due to "Resource busy" error.

This sometimes occurs and other times doesn't occur.

Temporary solutions include trying downloading the file through another browser, moving the file somewhere else before opening it, or trying again later, but they don't always fix the issue.

How can I fix this error for a permanent solution?

Best Answer

I'm having this issue as well and its driving me crazy. Here is what I found out but I don't have a solution.

After I download a .dmg (image) file through my browser, even though I do not open or mount the image the following things occur:

  1. diskimage process runs against the downloaded dmg. Duration of this seems to last for quite a bit of time. (in my example it was about 12 seconds on my machine for this 160MB image file but with larger images it could last longer and depends on machine resources)
  2. A directory appears in my /private/tmp with a copy of the image. When the diskimage process completes, this directory disappears.

If you try to mount the image while the above conditions are occurring, you will get a resource busy error.

How do you know when you can mount the image? Use the lsof command. And if you are using homebrew, you can install a handy utility called watch. Watch just runs the command repeatedly ever 1 second (-n 1)

So use a command like this from the terminal. In my example, I'm just downloading the image file to my Downloads directory. I'm not trying to open the image or mount the image.

watch -n 1 "lsof +D /Users/gman/Downloads" 

After the download finishes, then the output of the command shows this:

Every 1.0s: lsof +D /Users/gman/Downloads                          w4sp Sat Feb 20 10:18:06 2021

COMMAND     PID USER   FD   TYPE DEVICE  SIZE/OFF    NODE NAME
diskimage 46638 gman    3r   REG    1,5 159570818 8771639 /Users/gman/Downloads/Notion-2.0.11.dmg

When the diskimage entry disappears from the lsof command (and this may take some time), you can then open image and mount it without getting the resource busy message.