Apple Disk Image

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Mac OS X Disk Image.png
The icon represents an internal hard drive within a generic file icon.
Filename extension .dmg, .smi, .img
Internet media type application/x-apple-diskimage
Uniform Type Identifier,
Developed by Apple Inc.
Type of format disk image

Apple Disk Images are disk image files commonly used by the Mac OS X operating system. When opened, an Apple disk image is "mounted" as a volume within the Finder. Several Apple proprietary disk image formats can be used to create these images, including the Universal Disk Image Format (UDIF) and the New Disk Image Format (NDIF). Apple disk images usually have the .dmg file extension.

Apple disk images allow secure password protection as well as file compression and hence serves both security and file distribution functions; they are most commonly used to distribute software over the Internet.


Apple originally created their disk image formats because the resource fork used by Mac applications could not easily be transferred over heterogeneous networks such as the Internet. Even as the use of resource forks declined with Mac OS X, disk images remained the standard software distribution format. Disk images allow the distributor to control the Finder's presentation of the window, which is commonly used to instruct the user to copy the application to the correct folder.

Universal Disk Image Format (UDIF) is the native disk image format for Mac OS X. Disk images in this format typically have a .dmg extension.[1] New Disk Image Format (NDIF) was the previous default disk image format in Mac OS 9,[1] and disk images with this format generally have a .img (not to be confused with raw .img disk image files) or .smi file extension. Files with the .smi extension are actually applications that mount an embedded disk image, thus a "Self Mounting Image", and are intended only for Mac OS 9 and earlier.[2][3] A previous version of the format, intended only for floppy disk images, is usually referred to as "Disk Copy 4.2" format, after the version of the Disk Copy utility that was used to handle these images.[1] A similar format that supported compression of floppy disk images is called DART.[1][4] Apple disk image files are published with a MIME type of application/x-apple-diskimage.

Different file systems can be contained inside these disk images, and there is also support for creating hybrid optical media images that contain multiple file systems.[1] Some of the file systems supported include Hierarchical File System (HFS), HFS Plus, File Allocation Table (FAT), ISO9660 and Universal Disk Format (UDF).[1][3]

Apple disk images can be created using utilities bundled with Mac OS X, specifically Disk Copy in Mac OS X v10.2 and earlier and Disk Utility in Mac OS X v10.3 and later. These utilities can also use Apple disk image files as images for burning CDs and DVDs. Disk image files may also be managed via the command line using the hdiutil utility. The format can also be opened by MagicISO and the freeware MagicDisc on Microsoft Windows, along with several free software implementations[citation needed].

UDIF data format[edit]

Apple disk image files are essentially raw disk images (i.e. contain block data) with some added metadata, optionally with one or two layers applied that provide compression and encryption. In hdiutil these layers are called CUDIFEncoding and CEncryptedEncoding.[1]

UDIF supports ADC (an old proprietary compression format by Apple), zlib, and bzip2 (Mac OS X v10.4 and later only) compression internally.


The header can be described using the following C structure. All values are little-endian (Apple II byte ordering)

typedef struct
    uint32_t magic;
    uint8_t  creator[4];
    uint16_t headerLength;
    uint16_t version;
    uint32_t format;
    uint32_t flags
    uint32_t numOfBlocks;
    uint32_t startOffset;
    uint32_t fileLength;
    uint32_t commentOffset;
    uint32_t commentLength;
    uint32_t creatorOffset;
    uint32_t creatorLength;
    uint8_t  padding[16];
} appleDiskImage_t

Here is an explanation:

Position(in Hex) Length (in bytes) Description
000 4 The integer constant '2IMG'. This integer should be little-endian, so on the Apple IIgs, this is equivalent to the four characters 'GMI2'; in ORCA/C 2.1, you can use the integer constant '2IMG'.
004 4 A four-character tag identifying the application that created the file.
008 2 The length of this header, in bytes. Should be 52.
00A 2 The version number of the image file format. Should be 1.
00C 4 The image format.
010 4 Flags
014 4 The number of 512-byte blocks in the disk image. This value should be zero unless the image format is 1 (ProDOS order).
018 4 Offset to the first byte of the first block of the disk in the image file, from the beginning of the file. The disk data must come before the comment and creator-specific chunks.
01C 4 Length of the disk data in bytes. This should be the number of blocks * 512.
020 4 Offset to the first byte of the image comment. Can be zero if there's no comment. The comment must come after the data chunk, but before the creator-specific chunk. The comment, if it exists, should be raw text; no length byte or C-style null terminator byte is required (that's what the next field is for).
024 4 Length of the comment chunk. Zero if there's no comment.
028 4 Offset to the first byte of the creator-specific data chunk, or zero if there is none.
02C 4 Length of the creator-specific chunk; zero if there is no creator-specific data.
030 16 Reserved space; this pads the header to 64 bytes. These values must all be zero.

Image format field[edit]

The image format is indicated as one of the following values:

Format Value
DOS 3.3 Order 0
ProDOS Order 1
Nibblized data 2


The flags field contains bit flags that specify details about the disk image. Bits not defined here must be zero.

Bit Description
31 If this bit is set, the disk image is locked and no changes should be permitted to the disk data it contains. This is used by emulators to provide support for write-protecting disk images.
8 If this bit is set, the low byte of the flags field contains the DOS 3.3 volume number of the disk image. This bit should only be set for DOS 3.3 disk images. If the disk is DOS 3.3 format (the image format is 0), and this bit is 0, volume number 254 is assumed.
7-0 The DOS 3.3 volume number, from 0-254, if bit 8 is set. Otherwise these bits should be 0.



In Mac OS X v10.2.3, Apple introduced Compressed Disk Images[5] and Internet-Enabled Disk Images for use with the Apple utility Disk Copy, which was later integrated into Disk Utility in 10.3. The Disk Copy application had the ability to display a multi-lingual software license agreement before mounting a disk image. The image will not be mounted unless the user indicates agreement with the license.[6]

Currently, the only way to open a .dmg disk image in Mac OS 9 is to use either the developer version of Disk Copy (version 6.4), or a beta version of the unreleased 6.5. However, both versions can only open uncompressed images; compressed Disk Images are unusable on Mac OS 9.[citation needed]


Apple has not released any documentation on the format, but attempts to reverse engineer parts of the format have been successful. Free software implementations include dmg2img[7] and DMGExtractor.[8]

The encrypted layer was reverse engineered in an implementation called VileFault[9] (a spoonerism of FileVault), and dmg2img and DMGExtractor have since implemented support for encrypted images. DMG files can be converted into ISO files using software like PowerISO.[10][11]

There are few options available to extract files or mount the proprietary Apple Disk Image format. The supported features are limited because of the proprietary nature of the format.

The well-known cross-platform and GPL licensed format conversion utilities are:[citation needed]

dmg2img[7] was originally written in Perl; however, the Perl version is no longer maintained, and the project was rewritten in C. Currently, without additional tools, the resulting images may be mounted only under Mac OS X and under Linux (provided hfsplus support has been enabled). UDIF ADC-compressed images have been supported since version 1.5.

DMGExtractor[8] is written in Java with GUI, and it supports more advanced features of dmg including AES-128 encrypted images but not UDCO images.

In Windows, most dmg images can be opened using several other programs such as Acute Systems TransMac, HFSExplorer, 7-Zip, UltraISO, and IsoBuster. MacDrive[12] can also mount simple dmg files as drives under windows, but not sparse disk or encrypted dmgs.

In Linux and possibly other Unix flavors, most .dmg files can be burned to CD/DVD using any CD-burner program (using cdrecord directly or a front-end such as K3B or Brasero) or directly mounted to a mountpoint (e.g. mount -o loop,ro -t hfsplus imagefile.dmg /mnt/mountpoint).

PowerISO is a proprietary, cross platform, Freeware CLI tool that runs on Linux; it can convert most proprietary image formats to ISO, and newer versions support .dmg.

See also[edit]


  1. ^ a b c d e f g "hdiutil man page". Archived from the original on 25 December 2008. Retrieved 2008-11-30. 
  2. ^ "Software Downloads: Formats and Common Error Messages". Retrieved 2009-05-06. 
  3. ^ a b "Mac OS X: Using Disk Copy disk image files". Retrieved 2013-04-25. 
  4. ^ "DART 1.5.3: Version Change History". Retrieved 2013-04-25. 
  5. ^ "Re: Some apps refuse to launch in 10.2.8! (OT, but very important)". 
  6. ^ "Guides". Apple. Retrieved 2010-10-27. 
  7. ^ a b "dmg2img". Archived from the original on 29 November 2010. Retrieved 2010-10-27. 
  8. ^ a b "DMGExtractor". Retrieved 2011-01-03. 
  9. ^ "VileFault". 2006-12-29. Retrieved 2010-10-27. 
  10. ^ "How To Convert DMG To ISO in Windows, Linux & Mac". 
  11. ^ "Convert DMG To ISO using PowerISO". Retrieved 2009-02-15. 
  12. ^ MacDrive Features / Boot Camp / System Requirements /. "MacDrive Home page". Mediafour. Archived from the original on 4 October 2010. Retrieved 2010-10-27. 

External links[edit]