Apple - How do I create a DMG file from a directory?

If you want to do it from the command line, hdiutil will provide more control than Disk Utility over how the DMG is created. As an example, you can use hdiutil like so:

hdiutil create -volname WhatYouWantTheDiskToBeNamed -srcfolder /path/to/the/folder/you/want/to/create -ov -format UDZO name.dmg

See man hdiutil for more details.


On Yosemite this did it for me too.

Made a small function:

dmg(){
  hdiutil create -fs HFS+ -srcfolder "$1" -volname "$2" "$2.dmg"
}

Usage in Terminal:

dmg /My/Source/Folder NameOfDmg

Some step by step instructions can be found here.

After opening Disk Utility:

  1. Click the New Image icon
  2. Place the contents of folder/directory into the newly created disk image.