Skip to content

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.

4 min read

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

  1. Open Disk Utility and choose File, New Image, Image from Folder.
  2. Pick the folder.
  3. Choose Image Format: compressed for archiving, read/write if you will keep adding to it.
  4. Choose Encryption if you want a password. 128-bit AES is quicker, 256-bit AES is stronger.
  5. 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.dmg

Which format

FormatUse for
UDZO, compressedArchives that open on any Mac
ULFO or ULMOSmaller archives for recent Macs
UDRW, read/writeAn image you keep adding to
Sparse bundleA 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.dmg

Once 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.

Read next