# Apple Disk Image

From Wikipedia, the free encyclopedia

| This article relies on references to primary sources. Please add references to secondary or tertiary sources. (July 2011)

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 (UTI) | `com.apple.disk-image, com.apple.disk-image-smi`
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.

## Overview[ edit ]

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.

### Header[ edit ]

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

### Flags[ edit ]

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.

## Support[ edit ]

### Macintosh[ edit ]

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]

### Non-Macintosh[ edit ]

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
- DMGEXtractor
- PeaZip
- 7zip

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 ]

- cloop
- DiskImageMounter
- Installer (Mac OS X)
- RUNZ
- Sparse image

## References[ 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 ]

- Demystifying DMG A detailed discussion of the DMG file format and mounting it on iOS and Mac OS X
- Apple Developer Connection A Quick Look at PackageMaker and Installer
- O'Reilly Mac DevCenter Tip 16-5. Create a Disk Image from a Directory in the Terminal
- `hdiutil(1)` – Darwin and Mac OS X General Commands Manual

Archive formats

Archiving only

- ar
- cpio
- shar
- tar
- LBR
- BagIt

Compression only

- bzip2
- gzip
- lzip
- LZMA
- lzop
- xz
- SQ
- compress

Archiving and compression

- 7z
- ACE
- ARC
- ARJ
- B1
- Cabinet
- cfs
- cpt
- DGCA
- .dmg
- .egg
- GCA
- kgb
- LHA
- LZX
- MPQ
- PEA
- qda
- RAR
- rzip
- sit
- SQX
- UDA
- UHARC
- Xar
- zoo
- ZIP

Software packaging and distribution

- APK
- app
- deb
- pkg (OS X)
- RPM
- RUNZ
- MSI
- JAR
  - WAR
  - RAR (Java)
  - EAR

Document packaging and distribution

- OEB Package Format
- OEBPS Container Format
- Open Packaging Conventions
- PAQ

- Comparison
  - type
- List

Disk image file formats

Optical discs

- CCD/IMG/SUB
- CUE/BIN
- CSO
- DAA
- IBP/IBQ
- ISO
- ISZ
- MDS/MDF
- MDX
- NRG
- UIF

Hard disks

- DMG
- FVD
- IMG
- ISO
- NDIF
- QCOW
- UDIF
- VDI
- VHD
- VMDK
- WIM

Floppy disks

- ADF/ADZ
- DC42/DART
- DCF
- DMS
- IMG/IMA/IMZ
- VFD

Flash drives | ISO
CD-DA | Disc Description Protocol
Comparison of disc image software

Retrieved from "http://en.wikipedia.org/w/index.php?title=Apple_Disk_Image&oldid=604316924"
Categories:

- Computer file formats
- Archive formats
- OS X
- Disk images
- Compression file systems

Hidden categories:

- Articles lacking reliable references from July 2011
- All articles lacking reliable references
- All articles with unsourced statements
- Articles with unsourced statements from December 2013
- Articles with unsourced statements from July 2011