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 (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.

Trailer[edit]

The trailer can be described using the following C structure.[5] All values are big-endian (PowerPC byte ordering)

typedef struct {
       uint8_t     Signature[4];
       uint32_t Version;
       uint32_t HeaderSize;
       uint32_t Flags;                 
       uint64_t RunningDataForkOffset;
       uint64_t DataForkOffset;
       uint64_t DataForkLength;
       uint64_t RsrcForkOffset;     
       uint64_t RsrcForkLength;        
       uint32_t SegmentNumber;
       uint32_t SegmentCount;
       uuid_t   SegmentID;
       uint32_t DataChecksumType;
       uint32_t DataChecksumSize;
       uint32_t DataChecksum[32];
       uint64_t XMLOffset; 
       uint64_t XMLLength; 
       uint8_t  Reserved1[120];
       uint32_t ChecksumType;
       uint32_t ChecksumSize;
       uint32_t Checksum[32];
       uint32_t ImageVariant;
       uint64_t SectorCount;
       uint32_t reserved2;
       uint32_t reserved3;
       uint32_t reserved4;
} __attribute__((__packed__)) UDIFResourceFile;

Here is an explanation:

Position(in Hex) Length (in bytes) Description
000 4 Magic bytes ('koly').
004 4 File version (current is 4)
008 4 The length of this header, in bytes. Should be 512.
00C 4 Flags.
010 8 Unknown.
018 8 Data fork offset (usually 0, beginning of file)
020 8 Size of data fork (usually up to the XMLOffset, below)
028 8 Resource fork offset, if any
030 8 Resource fork length, if any
034 4 Segment number. Usually 1, may be 0
038 4 Segment count. Usually 1, may be 0
03C 16 128-bit GUID identifier of segment
040 4 Data fork checksum type
044 4 Data fork checksum size
048 128 Data fork checksum
C8 8 Offset of property list in DMG, from beginning
D0 8 Length of property list
D8 120 Reserved bytes
150 4 Master checksum type
154 4 Master checksum size
158 128 Master checksum
1D8 4 Unknown, commonly 1
1DC 8 Size of DMG when expanded, in sectors
1E4 12 Zeroes

Support[edit]

Macintosh[edit]

In Mac OS X v10.2.3, Apple introduced Compressed Disk Images[6] 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.[7]

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[8] and DMGExtractor.[9]

The encrypted layer was reverse engineered in an implementation called VileFault[10] (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.[11][12]

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[8] 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[9] 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[13] 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]

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. ^ "Demystifying the DMG File Format". 
  6. ^ "Re: Some apps refuse to launch in 10.2.8! (OT, but very important)". 
  7. ^ "Guides". Apple. Retrieved 2010-10-27. 
  8. ^ a b "dmg2img". Archived from the original on 29 November 2010. Retrieved 2010-10-27. 
  9. ^ a b "DMGExtractor". Retrieved 2011-01-03. 
  10. ^ "VileFault". 2006-12-29. Retrieved 2010-10-27. 
  11. ^ "How To Convert DMG To ISO in Windows, Linux & Mac". 
  12. ^ "Convert DMG To ISO using PowerISO". Retrieved 2009-02-15. 
  13. ^ 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]