Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Mac OS sparse image (.sparseimage) format

The Mac OS sparse image (.sparseimage) format is one of the disk image formats supported natively by Mac OS.

Overview

A sparse disk image consists of:

  • header data
  • bands data

Characteristics

CharacteristicsDescription
Byte orderbig-endian
Date and time valuesN/A
Character stringsN/A

The number of bytes per sector is 512.

Header data

The header data is 4096 bytes in size and consist of:

  • file header
  • band numbers array
  • trailing data, which should be filled with 0-byte values

File header

The file header is 64 bytes in size and consist of:

OffsetSizeValueDescription
04"sprs"Signature
44Unknown (format version?), seen 3
84Number of sectors per band
124Unknown, seen 1
164The media data size in sectors
20120Unknown (0-byte values)
324Unknown
36280Unknown (0-byte values)

Band numbers array

The band numbers array consists of:

  • one or more band numbers

Band number

A band number is 4 bytes in size and consist of:

OffsetSizeValueDescription
04Band number, where 0 indicates a sparse range and any other value refers to a location in the media data

Where the corresponding media offset can be calculated as following:

media_offset = (band_number - 1) * sectors_per_band * 512

The offset of band data can be calculated as following:

band_data_offset = 4096 + (array_index * sectors_per_band * 512)

For example if the first array entry contains a band number of 4, then the band data is located at offset 4096 and the corresponding media offset is: 3 * sectors_per_band * 512.