DMG stands for “Disk Image,” a file format that packages data exactly as it would appear on a physical disk. It acts like a virtual drive you can mount, browse, and unmount on macOS without needing extra hardware.
Disk images store everything from entire operating systems to single documents in one compressed, verifiable bundle. Because they preserve folder structures and metadata, they are ideal for software distribution and secure backups.
Core Anatomy of a DMG File
File Structure and Metadata
A DMG file wraps its contents inside a read-only or read-write container. This container holds a file system that macOS can interpret just like a USB stick or hard drive.
Metadata tracks permissions, creation dates, and checksums so integrity checks remain intact across transfers. Developers often embed license agreements and background images to guide users during installation.
Compression and Encryption Layers
The format supports zlib, bzip2, and LZFSE compression to shrink payload size. Users can add AES-256 encryption, turning a simple archive into a password-protected vault.
Practical Uses on macOS
Software Distribution
Developers ship apps in DMG files to ensure every user receives identical bits. A typical workflow compresses the app bundle, adds a symbolic link to the Applications folder, and spruces up the window with branded graphics.
Backup and Archiving
Users drag entire folders into a new disk image, set it to read-only, and compress it for safekeeping. Encrypted DMGs protect tax documents or client files without needing third-party tools.
Time Machine can mount these images as secondary destinations when network storage is limited. The same image can later be restored to a new Mac exactly as it was.
Creating Your First DMG
Using Disk Utility
Open Disk Utility, choose File > New Image > Image from Folder, and pick your source. Select read/write if you plan to add files later, or read-only for a fixed snapshot.
Set encryption and compression options in the same dialog. Click Save, and macOS builds the image while displaying a progress bar.
Command-Line with hdiutil
Run hdiutil create -srcfolder MyFolder -format UDZO -o MyImage.dmg to compress on the fly. Append -encryption AES-256 to add a passphrase prompt.
Advanced users chain hdiutil with xargs or find to batch-convert multiple directories into separate images overnight.
Mounting and Unmounting Safely
Finder Method
Double-clicking a DMG causes macOS to mount it under /Volumes and open a Finder window. Eject the virtual disk by clicking the eject icon or pressing Cmd-E.
Terminal Method
Type hdiutil attach MyImage.dmg to mount and hdiutil detach /Volumes/MyImage to unmount. This approach is handy when automating workflows with shell scripts.
Verification and Integrity Checks
Built-in Checksum Tools
Disk Utility can verify a DMG before mounting to detect corruption. Choose Images > Check, select the file, and let macOS compute its internal checksum.
Manual Hashing
Generate SHA-256 hashes using shasum -a 256 MyImage.dmg and compare the output with a value published by the developer. Mismatched hashes signal tampering or download errors.
Cross-Platform Compatibility
Reading DMGs on Windows
Third-party tools like 7-Zip or TransMac extract DMG contents on Windows. They treat the image as a compressed archive and ignore macOS-specific metadata.
Windows cannot natively mount DMGs because the file system inside is usually HFS+ or APFS. Users must extract files rather than run installers directly.
Linux Handling
Install hfsprogs and libdmg-hfsplus to mount read-only DMGs on Linux. Use mount -o loop,ro MyImage.dmg /mnt/dmg after loading kernel modules.
Advanced Customization
Layout and Background Art
Designers can set a custom background and arrange icons using the View Options panel in Finder. Save the layout with bless --folder /Volumes/MyImage --openfolder /Volumes/MyImage to lock it into the image.
Code Signing and Notarization
Sign the DMG with a Developer ID certificate so Gatekeeper recognizes it as trusted. Upload the image to Apple’s notarization service to receive a ticket stapled to the file.
Unsigned DMGs trigger security warnings on modern macOS versions. Notarization removes friction for end users downloading from the web.
Common Pitfalls and Quick Fixes
Corrupted Downloads
Re-download the DMG if mounting fails with a “no mountable file systems” error. A partial download often breaks internal structures beyond repair.
Permission Conflicts
If files appear locked, mount the image read-write using hdiutil attach -readwrite -noverify and adjust POSIX permissions inside Terminal.
Remember to convert back to read-only with hdiutil convert before redistribution to avoid accidental edits.
Alternatives to DMG
Pkg and Mpkg Installers
For system-level software, Apple recommends signed .pkg bundles that can run scripts and install kernel extensions. These packages are not disk images but can be wrapped inside one for transport.
ZIP and TAR Archives
Cross-platform projects often ship as ZIP files because every OS can open them without special tools. The downside is the loss of resource forks and extended attributes on older macOS versions.
Future Outlook
APFS and Beyond
Apple is moving toward APFS snapshots and signed system volumes, which may reduce the need for traditional DMGs. Developers already experiment with signed archive formats that preserve notarization without mounting overhead.
Yet the simplicity and user familiarity of DMG files ensure they will remain a staple for indie apps and personal backups for years to come.