viewhack

Open a Mac .dmg on Windows or Linux

A .dmg is a Mac disk image: usually an app installer, sometimes a shared folder or a backup. Windows, Linux and Chromebooks cannot open one. Drop it here to see every file and folder inside and save any one of them, with the app’s name, version and the macOS it needs.

The image is read by this tab on your device, a piece at a time, and is not uploaded. A 1 GB image is never loaded whole.

What it shows

What is inside a .dmg

A disk, cut into compressed chunks
A .dmg holds the bytes of a whole disk: a partition map and a volume with its files. The disk is cut into chunks of up to about 1 MB, and each chunk is compressed on its own, so one file can be read without unpacking the rest. Free space is not stored at all. At the end of the file sits a 512-byte trailer starting with koly, which points at the table of chunks (an XML property list, or a classic Mac resource fork in very old images).
The formats, by their hdiutil names
UDZO: zlib, the usual “compressed” image and the most common. UDBZ: bzip2, smaller and slower (Mac OS X 10.4 and later). ULFO: LZFSE, Apple’s own fast compressor (OS X 10.11 and later). ULMO: LZMA (macOS 10.15 and later). UDCO: the old ADC compression. UDRO and UDRW: not compressed. This page reads all of them except ULMO.
A worked example
The installer of the window manager Rectangle 2.0.2 is a 4.5 MB file. Inside is a 35 MB disk with a GPT partition map and one HFS+ partition named “disk image”; 24 MB of it is free space, stored as nothing. Seventeen zlib chunks hold 10 MB of disk in 3.5 MB. The volume holds 156 files (9.6 MB): Rectangle.app, the Applications link and a background picture. The app’s Info.plist says bundle ID com.knollsoft.Rectangle, version 2.0.2, build 109, macOS 14.0 or later, and its program carries both Intel and Apple silicon code.
HFS+ or APFS
Most installers use HFS+, which this page reads. Images made on newer Macs can hold an APFS volume instead; the page recognises APFS and says so, but cannot list its files yet.

How the file is read

Written for this site
The trailer, chunk tables, partition maps and the HFS+ catalog are read by viewhack’s own code, written from Apple’s Technical Note TN1150 (HFS Plus Volume Format), the UEFI specification (GPT) and public descriptions of the UDIF format. The bzip2 and ADC decoders were written from their format descriptions; LZFSE and LZVN are a port of Apple’s open-source reference decoder (BSD licence); zlib uses the vendored fflate library. No code from GPL tools such as dmg2img or libdmg-hfsplus is used.
A piece at a time
Opening an image reads only its last 512 bytes, the chunk table and the chunks that hold the partition map and the catalog of files. Saving a file decompresses just the chunks that file lives in. That is why a large image opens quickly and does not fill your phone’s memory.
Tested on
The real Rectangle 2.0.2 installer (MIT licence), and generated images that use every chunk kind (stored, zero-fill, free space, zlib, bzip2, ADC and LZFSE), GPT, Apple Partition Map and unpartitioned disks, HFS+ and HFSX, files split across many fragments, HFS+-compressed files, a resource fork, a licence in plain text and in RTF, and an encrypted image. The LZFSE decoder is checked against files made by Apple’s reference encoder.

What this cannot do

Other ways to open them

Windows
7-Zip (free) lists and extracts most .dmg files, including APFS ones in recent versions. HFSExplorer (free) reads HFS+ images.
Linux
7-Zip (the 7z command) extracts most images; dmg2img converts one to a raw image that the kernel’s hfsplus driver can mount; apfs-fuse reads APFS.
Mac
Double-click mounts it. In Terminal, hdiutil imageinfo shows the same facts as this page, and hdiutil convert changes the format.