Turn a folder into one compressed, optionally encrypted, disk image on your Mac
A disk image bundles a folder into a single file you can compress, encrypt and archive. How to make one in Disk Utility or Terminal, and which format to pick.
You want to archive an old project folder, send a set of files as one download, or keep something private in a password-protected file. A disk image does all three, and your Mac can make one without extra software.
In Disk Utility
- Open Disk Utility and choose File, New Image, Image from Folder.
- Pick the folder.
- Choose Image Format: compressed for archiving, read/write if you will keep adding to it.
- Choose Encryption if you want a password. 128-bit AES is quicker, 256-bit AES is stronger.
- Save.
In Terminal
# Compressed, read only
hdiutil create -volname "Archive" -srcfolder ~/Projects/Old -ov -format UDZO ~/Desktop/Old.dmg
# Better compression, macOS 10.15 and later
hdiutil create -volname "Archive" -srcfolder ~/Projects/Old -ov -format ULMO ~/Desktop/Old.dmg
# Encrypted, asks for a password
hdiutil create -volname "Private" -srcfolder ~/Private -encryption AES-256 -format UDZO ~/Desktop/Private.dmgWhich format
| Format | Use for |
|---|---|
| UDZO, compressed | Archives that open on any Mac |
| ULFO or ULMO | Smaller archives for recent Macs |
| UDRW, read/write | An image you keep adding to |
| Sparse bundle | A growing image, for example on a network drive |
How much it saves
Compression helps with text, code and documents, often a lot. Photos, videos and music are already compressed and barely shrink. Check the result:
du -sh ~/Projects/Old ~/Desktop/Old.dmgOnce you have checked the image opens, the original folder can go to the Trash. Old disk images you no longer need are covered in disk images taking up space, and archiving strategy in archiving old projects.
Common questions
How do I make a disk image from a folder on a Mac?
Open Disk Utility and choose File, New Image, Image from Folder. Or use hdiutil create with -srcfolder in Terminal.
Does a DMG compress files?
The compressed formats do. Text and documents shrink a lot, while photos and video barely change because they are already compressed.
How do I password protect a folder on a Mac?
Make an encrypted disk image of it with Disk Utility or hdiutil, then delete the original once you have checked the image opens.