hdiutil convert/rsize resource temporarily unavailable

The problem appears to happen when you unmount the image using umount.

Remount the image (either using hdiutil attach or just double click the image) and use the command hdiutil detach it again. This will unmount and eject the image.

hdiutil detach /Volumes/<your image>

Another possibility is that the disk image is still mounted (from previous work on it). In this case, just select the eject icon.

Afterwards, the hdiutil convert worked great.


In my case something was trying to access the image. What finally worked:

sudo lsof | grep ~/Unix.sparsebundle/
sudo kill -9 889
resize -size 100g ~/Unix.sparsebundle/

If you are accessing a disk image over a network then it's possible to have various operations interrupted if you encounter any kind of network issue, which can result in the image becoming "temporarily unavailable" when you try to resume whatever you were doing.

This happens because only a single system can have a disk image mounted at once, otherwise corruption could/will occur, but the locking mechanism for preventing double-access can end up being left in an inconsistent state, so even if you only have a single system accessing an image, you can end up with this error, as hdiutil thinks the image is already open on another system.

As others have pointed out, a restart can resolve this; I'm not actually sure why, as I'm not clear on how hdiutil/macOS marks an image as in-use. For a sparse bundle this has something to do with the token file, and there's a handy workaround if you don't want to have to restart.

NOTE: You must be absolutely certain that yours is the only system accessing this disk image, fiddling with the token file while an image is already mounted could destroy your image completely! Always have backups wherever possible, and be very careful at all times.

  1. Open Terminal.app
  2. If your image is on a remote share, connect to it now
  3. Navigate into the sparse bundle in the Terminal (type cd (with trailing space) then drag your sparse bundle file onto the Terminal window, hit enter)
  4. Rename the old token (mv token{,.old})
  5. Create a new copy of the token (cp token{.old,})
  6. If necessary, correct the permissions on the new token (chown 'user:group' token, with the correct user/group, it should match the user:group of the Info.plist file in the same folder.

After copying the token in this way, you should now be able to use hdiutil attach /path/to/image as normal to attach and mount the image.

NOTE: Be very careful using this method; I move the original out of the way rather than discarding it, so that it is always possible to recover it if anything goes wrong.