Not every Apple disk image is one UDIF file. This page covers the sparse forms, images split into segments, and the older NDIF format. The sparse image layout comes from the libmodi project’s documentation; no real sparse image was available to compare it with, so it was checked only against hand-built files.
Sparse images (.sparseimage)
A sparse image grows as data is written to the disk. The disk is cut into bands of a fixed size, and a band is stored in the file only once something has been written to it, in the order the bands were first written. Numbers are big-endian.
0Signaturesprs4 bytes4Fields version and sizes60 bytes64Band table one 32-bit entry for each stored bandto byte 40964096Bands one after anothervaries
| Offset | Size | Field |
|---|---|---|
| 0 | 4 | Signature, sprs |
| 4 | 4 | Version; 3 is the value seen |
| 8 | 4 | Sectors per band (512 bytes each) |
| 12 | 4 | Not documented |
| 16 | 4 | The disk’s size, in sectors |
| 20 | 44 | Not documented |
| 64 | 4032 | Band table |
Entry n of the band table says which band of the disk is stored at file offset 4096 + n × band size. Bands are numbered from 1, and 0 marks an empty slot. A band with no entry reads as zeros.
Sparse bundles (.sparsebundle)
A sparse bundle is a folder, not a file: an Info.plist and its copy
Info.bckup, an empty token file, and a bands
folder with one file for each band, named with its number in hexadecimal. The
Info.plist gives the band size and the disk’s size. The explorer opens
one file at a time, so a bundle cannot be read yet.
Segmented images
A UDIF image can be split into several files, named .dmg,
.002.dmgpart, .003.dmgpart and so on. Each has its own
koly trailer, with its segment number and
the number of segments. In a segment, the running data fork offset says where that
file’s data starts within the data of the whole image, and the block tables’
compressed offsets count across all the segments.
One segment read alone gives the runs stored in it. The rest are in other files. The explorer opens one file at a time, so it reports the other segments’ runs as stored elsewhere.
NDIF
New Disk Image Format is the format before UDIF, usually with the extension
.img or .smi. Its data fork holds the sectors, and its block
map is in a resource fork. A browser is given a file’s data fork alone, and that holds
no signature to identify NDIF by: a data fork in NDIF cannot be told from raw data,
so the explorer can only say the file is not UDIF.