I could successfully use hdiutil for creating a dmg file for my program in Mountain Lion, but after upgrading to Yosemite (and after updating it to 10.10.1), when I execute

hdiutil create -srcfolder build/Thonny.app Thonny-0.2.5.dmg

I get following error:

hdiutil: create failed - error -5341

Verbose mode didn't reveal anything useful.

Folder build/Thonny.app contains a Python application.

Any idea what this error means and what to try next?

UPDATE: Looks like the number of files in my app affects the result. When I remove one of the files (doesn't matter which one), then the command is able to produce the result. Currently there are about 70 files and few folders under Thonny.app/Contents/MacOS

  • What's the command you type ? Nov 18, 2014 at 13:13
  • Try to set a filesize Nov 18, 2014 at 13:30
  • @Thomas, no luck, "hdiutil create -size 200k -srcfolder build/Thonny.app Thonny-0.2.5.dmg" gives me "hdiutil: create failed - Operation not permitted"
    – Aivar
    Nov 18, 2014 at 13:45
  • And with a sudo ? Nov 18, 2014 at 13:57
  • Same result with sudo
    – Aivar
    Nov 18, 2014 at 14:01

2 Answers 2


I had the same error -5341 and was able to work around it with the -megabytes option as suggested here.

hdiutil create -megabytes 130 Reassembly.dmg -srcfolder Reassembly

In this case the Reassembly directory is 107M and the resulting Reassembly.dmg is 97M. The -size 130m option did not work for me. My issue was intermittent - adding or removing one or two files would fix it or break it.

  • I had a similar problem, but had to use -megabytes 900 instead of -megabytes 130. Note that I didn't try any intermediate values, but just wanted to choose a number that I was hoping was "large enough". With a value of 130, I got the message hdiutil: create failed - No space left on device Dec 15, 2015 at 19:49

Looks like I found a workaround. If I do

hdiutil create -srcfolder build Thonny-0.2.5.dmg

instead of

hdiutil create -srcfolder build/Thonny.app Thonny-0.2.5.dmg

(ie provide the parent of the app folder instead of app folder itself), then it works.


You must log in to answer this question.

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