38

When trying to convert or resize a dmg image I get the error:

hdiutil: convert failed Resource Temporarily Unavailable error

or

hdiutil: resize: failed. Resource temporarily unavailable (35).

(hdiutil error code 35).

0

7 Answers 7

50

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>
3
  • 1
    The mounted images still appear in "Disk Utility" when you can remove them. Sep 20, 2015 at 1:07
  • 3
    I used 'hdiutil info" found the /dev then "hdiutil detach /dev/disk2". That way you don't have to remount the volume.
    – drudru
    Mar 29, 2018 at 22:29
  • This is it! I tried to use umount /Volumes/<your image>/ but it only unmount the image but still seeing the Apple read/write Media in Disk Utility...
    – Richard Fu
    Aug 20, 2019 at 1:34
5

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

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

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.

1

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.

2
  • Is there any other way to get the user and group to change the token's owner to? I can't find anything that seems to match user or group info in Info.plist (nor any of the other plist files in the bundle). Specifically, if it's at all helpful, I'm attempting to fix a Time Machine backup that was apparenly corrupted or something as I updated the system from MacOS Mojave to Catalina.
    – Patronics
    Mar 26, 2021 at 17:39
  • 1
    @PatrickL: ls -l Info.plist while cd'd into the sparsebundle should do the trick. In general you should just need it to match whichever user your system would be running as while accessing the image.
    – Haravikk
    Mar 27, 2021 at 19:03
1

What worked for me when trying to create macOS install iso:

  1. Create new folder
  2. Add folder to Spotlight > Privacy
  3. Mount with hdiutil attach to the subfolder of the new folder
  4. Now it can be unmounted with hdiutil detach
  5. Profit
1
  • This solved my issue, which was using yarn build to kick off electron-builder in a vite-electron app. Added the release directory to the Privacy list and voila. Surprising fix but very thankful!
    – Beau
    Jun 7, 2023 at 17:21
0

Sometimes you can't explain whats going on. For my case, the error message was that they could not read my dmg file created with createinstallmedia. After reboot, i noticed that the process had been mounting some temporary file. I had been following these steps: How to Create a Bootable macOS Big Sur ISO

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – nohillside
    Sep 15, 2022 at 6:54
-1

restart your machine and it run it again it should work.

1
  • 1
    We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.
    – Tetsujin
    May 22, 2017 at 8:07

You must log in to answer this question.

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