Create a Disk Image from a Folder with hdiutil

Turn an entire folder into a compressed .dmg disk image without any extra software.

macOSFileshdiutildisk-imageLow risk
Run hdiutil create with -srcfolder pointing at your folder to produce a single compressed .dmg file.

01Command

Command
$ hdiutil create -srcfolder ~/Desktop/Project -volname "Project" -format UDZO ~/Desktop/Project.dmg

02What it does

UDZO writes a compressed, read-only image — ideal for archiving or sending a folder as one attachment. The -volname sets the name shown when the image is mounted. To make a writable image instead, use -format UDRW. Larger folders take a minute or two; hdiutil prints progress as it copies.

03Risk

RiskLow risk
!Warning: The .dmg is read-only; edit files in the original folder and re-create the image.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-09-18 · Category: Files & Folders

06Related solutions