* Apple_Disk_Image.html: Wikipedia entry for UDIF, documents NDIF

(yes, it's incorrectly named).

* DMG.html: From http://newosxbook.com documents Apple UDIF (aka DMG)
disc image.

* FDISPEC.pdf: Documents FDI disc image.

* NRG_(file_format).html: Wikipedia entry for NRG disc image format,
documents fields.

* Virtual Hard Disk Format Spec_10_18_06.doc: Documents
VirtualPC/Hyper-V vhd and vhdx.

* Windows Imaging File Format.rtf: Documents Microsoft WIM disc image.

* qcow-image-format-version-1.html: Documents QCOW image format.

* qcow-image-format.html: Documents QCOW2 image format.

* vmdk_specs.pdf: Documents VMWare disc images.
This commit is contained in:
2014-06-15 23:10:54 +01:00
parent 077f8f98b4
commit 83917c650e
9 changed files with 35893 additions and 0 deletions

773
Apple_Disk_Image.html Normal file
View File

@@ -0,0 +1,773 @@
<!DOCTYPE html>
<html lang="en" dir="ltr" class="client-nojs">
<head>
<meta charset="UTF-8" />
<title>Apple Disk Image - Wikipedia, the free encyclopedia</title>
<meta name="generator" content="MediaWiki 1.24wmf7" />
<link rel="alternate" href="android-app://org.wikipedia/http/en.m.wikipedia.org/wiki/Apple_Disk_Image" />
<link rel="alternate" type="application/x-wiki" title="Edit this page" href="/w/index.php?title=Apple_Disk_Image&amp;action=edit" />
<link rel="edit" title="Edit this page" href="/w/index.php?title=Apple_Disk_Image&amp;action=edit" />
<link rel="apple-touch-icon" href="//bits.wikimedia.org/apple-touch/wikipedia.png" />
<link rel="shortcut icon" href="//bits.wikimedia.org/favicon/wikipedia.ico" />
<link rel="search" type="application/opensearchdescription+xml" href="/w/opensearch_desc.php" title="Wikipedia (en)" />
<link rel="EditURI" type="application/rsd+xml" href="//en.wikipedia.org/w/api.php?action=rsd" />
<link rel="copyright" href="//creativecommons.org/licenses/by-sa/3.0/" />
<link rel="alternate" type="application/atom+xml" title="Wikipedia Atom feed" href="/w/index.php?title=Special:RecentChanges&amp;feed=atom" />
<link rel="canonical" href="http://en.wikipedia.org/wiki/Apple_Disk_Image" />
<link rel="stylesheet" href="//bits.wikimedia.org/en.wikipedia.org/load.php?debug=false&amp;lang=en&amp;modules=ext.gadget.DRN-wizard%2CReferenceTooltips%2Ccharinsert%2CrefToolbar%2Cteahouse%7Cext.rtlcite%2Cwikihiero%7Cext.uls.nojs%7Cext.visualEditor.viewPageTarget.noscript%7Cmediawiki.legacy.commonPrint%2Cshared%7Cmediawiki.skinning.interface%7Cmediawiki.ui.button%7Cskins.vector.styles%7Cwikibase.client.init&amp;only=styles&amp;skin=vector&amp;*" />
<meta name="ResourceLoaderDynamicStyles" content="" />
<link rel="stylesheet" href="//bits.wikimedia.org/en.wikipedia.org/load.php?debug=false&amp;lang=en&amp;modules=site&amp;only=styles&amp;skin=vector&amp;*" />
<style>a:lang(ar),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}
/* cache key: enwiki:resourceloader:filter:minify-css:7:3904d24a08aa08f6a68dc338f9be277e */</style>
<script src="//bits.wikimedia.org/en.wikipedia.org/load.php?debug=false&amp;lang=en&amp;modules=startup&amp;only=scripts&amp;skin=vector&amp;*"></script>
<script>if(window.mw){
mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"Apple_Disk_Image","wgTitle":"Apple Disk Image","wgCurRevisionId":604316924,"wgRevisionId":604316924,"wgArticleId":30865034,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["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","Computer file formats","Archive formats","OS X","Disk images","Compression file systems"],"wgBreakFrames":false,"wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgMonthNamesShort":["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"wgRelevantPageName":"Apple_Disk_Image","wgIsProbablyEditable":true,"wgRestrictionEdit":[],"wgRestrictionMove":[],"wgWikiEditorEnabledModules":{"toolbar":true,"dialogs":true,"hidesig":true,"preview":false,"previewDialog":false,"publish":false},"wgBetaFeaturesFeatures":[],"wgMediaViewerOnClick":true,"wgVisualEditor":{"isPageWatched":false,"magnifyClipIconURL":"//bits.wikimedia.org/static-1.24wmf7/skins/common/images/magnify-clip.png","pageLanguageCode":"en","pageLanguageDir":"ltr","svgMaxSize":2048},"wikilove-recipient":"","wikilove-anon":0,"wgGuidedTourHelpGuiderUrl":"Help:Guided tours/guider","wgFlowTermsOfUseEdit":"By saving changes, you agree to our \u003Ca class=\"external text\" href=\"//wikimediafoundation.org/wiki/Terms_of_use\"\u003ETerms of Use\u003C/a\u003E and agree to irrevocably release your text under the \u003Ca rel=\"nofollow\" class=\"external text\" href=\"//creativecommons.org/licenses/by-sa/3.0\"\u003ECC BY-SA 3.0 License\u003C/a\u003E and \u003Ca class=\"external text\" href=\"//en.wikipedia.org/wiki/Wikipedia:Text_of_the_GNU_Free_Documentation_License\"\u003EGFDL\u003C/a\u003E","wgFlowTermsOfUseSummarize":"By clicking \"Summarize\", you agree to the terms of use for this wiki.","wgFlowTermsOfUseCloseTopic":"By clicking \"Close topic\", you agree to the terms of use for this wiki.","wgFlowTermsOfUseReopenTopic":"By clicking \"Reopen topic\", you agree to the terms of use for this wiki.","wgULSAcceptLanguageList":["en-us"],"wgULSCurrentAutonym":"English","wgFlaggedRevsParams":{"tags":{"status":{"levels":1,"quality":2,"pristine":3}}},"wgStableRevisionId":null,"wgCategoryTreePageCategoryOptions":"{\"mode\":0,\"hideprefix\":20,\"showcount\":true,\"namespaces\":false}","wgNoticeProject":"wikipedia","wgWikibaseItemId":"Q1228757"});
}</script><script>if(window.mw){
mw.loader.implement("user.options",function($,jQuery){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"editfont":"default","editondblclick":0,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"imagesize":2,"math":0,"minordefault":0,"newpageshidepatrolled":0,"nickname":"","norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"rcdays":7,"rclimit":50,"rows":25,"showhiddencats":false,"shownumberswatching":1,"showtoolbar":1,"skin":"vector","stubthreshold":0,"thumbsize":4,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":1,"watchdefault":0,"watchdeletion":0,"watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,
"useeditwarning":1,"prefershttps":1,"flaggedrevssimpleui":1,"flaggedrevsstable":0,"flaggedrevseditdiffs":true,"flaggedrevsviewdiffs":false,"usebetatoolbar":1,"usebetatoolbar-cgd":1,"multimediaviewer-enable":true,"visualeditor-enable":0,"visualeditor-betatempdisable":0,"visualeditor-enable-experimental":0,"visualeditor-enable-language":0,"visualeditor-hidebetawelcome":0,"wikilove-enabled":1,"mathJax":false,"echo-subscriptions-web-page-review":true,"echo-subscriptions-email-page-review":false,"ep_showtoplink":false,"ep_bulkdelorgs":false,"ep_bulkdelcourses":true,"ep_showdyk":true,"echo-subscriptions-web-education-program":true,"echo-subscriptions-email-education-program":false,"echo-notify-show-link":true,"echo-show-alert":true,"echo-email-frequency":0,"echo-email-format":"html","echo-subscriptions-email-system":true,"echo-subscriptions-web-system":true,"echo-subscriptions-email-other":false,"echo-subscriptions-web-other":true,"echo-subscriptions-email-edit-user-talk":false,
"echo-subscriptions-web-edit-user-talk":true,"echo-subscriptions-email-reverted":false,"echo-subscriptions-web-reverted":true,"echo-subscriptions-email-article-linked":false,"echo-subscriptions-web-article-linked":false,"echo-subscriptions-email-mention":false,"echo-subscriptions-web-mention":true,"echo-subscriptions-web-edit-thank":true,"echo-subscriptions-email-edit-thank":false,"echo-subscriptions-web-flow-discussion":true,"echo-subscriptions-email-flow-discussion":false,"gettingstarted-task-toolbar-show-intro":true,"uls-preferences":"","language":"en","variant-gan":"gan","variant-iu":"iu","variant-kk":"kk","variant-ku":"ku","variant-shi":"shi","variant-sr":"sr","variant-tg":"tg","variant-uz":"uz","variant-zh":"zh","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":
false,"searchNs15":false,"searchNs100":false,"searchNs101":false,"searchNs108":false,"searchNs109":false,"searchNs118":false,"searchNs119":false,"searchNs446":false,"searchNs447":false,"searchNs710":false,"searchNs711":false,"searchNs828":false,"searchNs829":false,"gadget-teahouse":1,"gadget-ReferenceTooltips":1,"gadget-DRN-wizard":1,"gadget-charinsert":1,"gadget-refToolbar":1,"gadget-mySandbox":1,"variant":"en"});},{},{});mw.loader.implement("user.tokens",function($,jQuery){mw.user.tokens.set({"editToken":"+\\","patrolToken":false,"watchToken":false});},{},{});
/* cache key: enwiki:resourceloader:filter:minify-js:7:369915ab579125627842c0da1e18ba20 */
}</script>
<script>if(window.mw){
mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax","ext.centralauth.centralautologin","mmv.head","ext.visualEditor.viewPageTarget.init","ext.uls.init","ext.uls.interface","ext.centralNotice.bannerController","skins.vector.js"]);
}</script>
<link rel="dns-prefetch" href="//meta.wikimedia.org" /><!--[if lt IE 7]><style type="text/css">body{behavior:url("/w/static-1.24wmf7/skins/vector/csshover.min.htc")}</style><![endif]--></head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-Apple_Disk_Image skin-vector action-view vector-animateLayout">
<div id="mw-page-base" class="noprint"></div>
<div id="mw-head-base" class="noprint"></div>
<div id="content" class="mw-body" role="main">
<a id="top"></a>
<div id="mw-js-message" style="display:none;"></div>
<div id="siteNotice"><!-- CentralNotice --></div>
<h1 id="firstHeading" class="firstHeading" lang="en"><span dir="auto">Apple Disk Image</span></h1>
<div id="bodyContent" class="mw-body-content">
<div id="siteSub">From Wikipedia, the free encyclopedia</div>
<div id="contentSub"></div>
<div id="jump-to-nav" class="mw-jump">
Jump to: <a href="#mw-navigation">navigation</a>, <a href="#p-search">search</a>
</div>
<div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><table class="metadata plainlinks ambox ambox-content ambox-Primary_sources" role="presentation">
<tr>
<td class="mbox-image">
<div style="width:52px;"><a href="/wiki/File:Question_book-new.svg" class="image"><img alt="Question book-new.svg" src="//upload.wikimedia.org/wikipedia/en/thumb/9/99/Question_book-new.svg/50px-Question_book-new.svg.png" width="50" height="39" srcset="//upload.wikimedia.org/wikipedia/en/thumb/9/99/Question_book-new.svg/75px-Question_book-new.svg.png 1.5x, //upload.wikimedia.org/wikipedia/en/thumb/9/99/Question_book-new.svg/100px-Question_book-new.svg.png 2x" data-file-width="262" data-file-height="204" /></a></div>
</td>
<td class="mbox-text"><span class="mbox-text-span">This article <b>relies on <a href="/wiki/Wikipedia:Verifiability" title="Wikipedia:Verifiability">references</a> to <a href="/wiki/Wikipedia:No_original_research#Primary.2C_secondary_and_tertiary_sources" title="Wikipedia:No original research">primary sources</a></b>. <span class="hide-when-compact">Please add references to <a href="/wiki/Wikipedia:No_original_research#Primary.2C_secondary_and_tertiary_sources" title="Wikipedia:No original research">secondary or tertiary sources</a>.</span> <small><i>(July 2011)</i></small></span></td>
</tr>
</table>
<table class="infobox" cellspacing="3" style="border-spacing:3px;width:22em;">
<tr>
<td colspan="2" style="text-align:center;"><a href="/wiki/File:Mac_OS_X_Disk_Image.png" class="image"><img alt="Mac OS X Disk Image.png" src="//upload.wikimedia.org/wikipedia/en/d/d4/Mac_OS_X_Disk_Image.png" width="128" height="128" data-file-width="128" data-file-height="128" /></a>
<div>The icon represents an <a href="/wiki/Internal_hard_drive" title="Internal hard drive" class="mw-redirect">internal hard drive</a> within a generic <a href="/w/index.php?title=File_icon&amp;action=edit&amp;redlink=1" class="new" title="File icon (page does not exist)">file icon</a>.</div>
</td>
</tr>
<tr>
<th scope="row" style="text-align:left;padding:0.225em 0;line-height:1.2em; padding-right:0.65em;;"><a href="/wiki/Filename_extension" title="Filename extension">Filename extension</a></th>
<td><code>.dmg, .smi, .img</code></td>
</tr>
<tr>
<th scope="row" style="text-align:left;padding:0.225em 0;line-height:1.2em; padding-right:0.65em;;"><a href="/wiki/Internet_media_type" title="Internet media type">Internet media&#160;type</a></th>
<td><code>application/x-apple-diskimage</code></td>
</tr>
<tr>
<th scope="row" style="text-align:left;padding:0.225em 0;line-height:1.2em; padding-right:0.65em;;"><a href="/wiki/Uniform_Type_Identifier" title="Uniform Type Identifier">Uniform Type Identifier&#160;(UTI)</a></th>
<td><code>com.apple.disk-image,<br />
com.apple.disk-image-smi</code></td>
</tr>
<tr>
<th scope="row" style="text-align:left;padding:0.225em 0;line-height:1.2em; padding-right:0.65em;;">Developed&#160;by</th>
<td><a href="/wiki/Apple_Inc." title="Apple Inc.">Apple Inc.</a></td>
</tr>
<tr>
<th scope="row" style="text-align:left;padding:0.225em 0;line-height:1.2em; padding-right:0.65em;;">Type of format</th>
<td><a href="/wiki/Disk_image" title="Disk image">disk image</a></td>
</tr>
</table>
<p><b>Apple Disk Images</b> are <a href="/wiki/Disk_image" title="Disk image">disk image</a> files commonly used by the <a href="/wiki/Mac_OS_X" title="Mac OS X" class="mw-redirect">Mac OS X</a> operating system. When opened, an Apple disk image is "<a href="/wiki/Mount_(computing)" title="Mount (computing)">mounted</a>" as a volume within the <a href="/wiki/Macintosh_Finder" title="Macintosh Finder" class="mw-redirect">Finder</a>. Several <a href="/wiki/Apple_Inc." title="Apple Inc.">Apple</a> 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 <i>.dmg</i> file extension.</p>
<p>Apple disk images allow secure password protection as well as <a href="/wiki/File_compression" title="File compression" class="mw-redirect">file compression</a> and hence serves both security and file distribution functions; they are most commonly used to distribute <a href="/wiki/Software" title="Software">software</a> over the <a href="/wiki/Internet" title="Internet">Internet</a>.</p>
<p></p>
<div id="toc" class="toc">
<div id="toctitle">
<h2>Contents</h2>
</div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#Overview"><span class="tocnumber">1</span> <span class="toctext">Overview</span></a></li>
<li class="toclevel-1 tocsection-2"><a href="#UDIF_data_format"><span class="tocnumber">2</span> <span class="toctext">UDIF data format</span></a>
<ul>
<li class="toclevel-2 tocsection-3"><a href="#Header"><span class="tocnumber">2.1</span> <span class="toctext">Header</span></a></li>
<li class="toclevel-2 tocsection-4"><a href="#Image_format_field"><span class="tocnumber">2.2</span> <span class="toctext">Image format field</span></a></li>
<li class="toclevel-2 tocsection-5"><a href="#Flags"><span class="tocnumber">2.3</span> <span class="toctext">Flags</span></a></li>
</ul>
</li>
<li class="toclevel-1 tocsection-6"><a href="#Support"><span class="tocnumber">3</span> <span class="toctext">Support</span></a>
<ul>
<li class="toclevel-2 tocsection-7"><a href="#Macintosh"><span class="tocnumber">3.1</span> <span class="toctext">Macintosh</span></a></li>
<li class="toclevel-2 tocsection-8"><a href="#Non-Macintosh"><span class="tocnumber">3.2</span> <span class="toctext">Non-Macintosh</span></a></li>
</ul>
</li>
<li class="toclevel-1 tocsection-9"><a href="#See_also"><span class="tocnumber">4</span> <span class="toctext">See also</span></a></li>
<li class="toclevel-1 tocsection-10"><a href="#References"><span class="tocnumber">5</span> <span class="toctext">References</span></a></li>
<li class="toclevel-1 tocsection-11"><a href="#External_links"><span class="tocnumber">6</span> <span class="toctext">External links</span></a></li>
</ul>
</div>
<p></p>
<h2><span class="mw-headline" id="Overview">Overview</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Apple_Disk_Image&amp;action=edit&amp;section=1" title="Edit section: Overview">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<p>Apple originally created their disk image formats because the <a href="/wiki/Resource_fork" title="Resource fork">resource fork</a> 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.</p>
<p>Universal Disk Image Format (UDIF) is the <a href="/wiki/Native_and_foreign_format" title="Native and foreign format">native</a> disk image format for <a href="/wiki/Mac_OS_X" title="Mac OS X" class="mw-redirect">Mac OS X</a>. Disk images in this format typically have a <i>.dmg</i> extension.<sup id="cite_ref-hdiutilman_1-0" class="reference"><a href="#cite_note-hdiutilman-1"><span>[</span>1<span>]</span></a></sup> New Disk Image Format (NDIF) was the previous default disk image format in <a href="/wiki/Mac_OS_9" title="Mac OS 9">Mac OS 9</a>,<sup id="cite_ref-hdiutilman_1-1" class="reference"><a href="#cite_note-hdiutilman-1"><span>[</span>1<span>]</span></a></sup> and disk images with this format generally have a <i>.img</i> (not to be confused with <a href="/wiki/IMG_(file_format)" title="IMG (file format)">raw <i>.img</i> disk image files</a>) or <i>.smi</i> file extension. Files with the <i>.smi</i> 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.<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span>[</span>2<span>]</span></a></sup><sup id="cite_ref-usingDiskCopy_3-0" class="reference"><a href="#cite_note-usingDiskCopy-3"><span>[</span>3<span>]</span></a></sup> A previous version of the format, intended only for <a href="/wiki/Floppy_disk" title="Floppy disk">floppy disk</a> images, is usually referred to as "Disk Copy 4.2" format, after the version of the <a href="/wiki/Disk_Copy" title="Disk Copy">Disk Copy</a> utility that was used to handle these images.<sup id="cite_ref-hdiutilman_1-2" class="reference"><a href="#cite_note-hdiutilman-1"><span>[</span>1<span>]</span></a></sup> A similar format that supported compression of floppy disk images is called DART.<sup id="cite_ref-hdiutilman_1-3" class="reference"><a href="#cite_note-hdiutilman-1"><span>[</span>1<span>]</span></a></sup><sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span>[</span>4<span>]</span></a></sup> Apple disk image files are published with a <a href="/wiki/MIME_type" title="MIME type" class="mw-redirect">MIME type</a> of <i>application/x-apple-diskimage</i>.</p>
<p>Different <a href="/wiki/File_systems" title="File systems" class="mw-redirect">file systems</a> can be contained inside these disk images, and there is also support for creating hybrid <a href="/wiki/Optical_media" title="Optical media" class="mw-redirect">optical media</a> images that contain multiple file systems.<sup id="cite_ref-hdiutilman_1-4" class="reference"><a href="#cite_note-hdiutilman-1"><span>[</span>1<span>]</span></a></sup> Some of the file systems supported include <a href="/wiki/Hierarchical_File_System" title="Hierarchical File System">Hierarchical File System (HFS)</a>, <a href="/wiki/HFS_Plus" title="HFS Plus">HFS Plus</a>, <a href="/wiki/File_Allocation_Table" title="File Allocation Table">File Allocation Table (FAT)</a>, <a href="/wiki/ISO9660" title="ISO9660" class="mw-redirect">ISO9660</a> and <a href="/wiki/Universal_Disk_Format" title="Universal Disk Format">Universal Disk Format (UDF)</a>.<sup id="cite_ref-hdiutilman_1-5" class="reference"><a href="#cite_note-hdiutilman-1"><span>[</span>1<span>]</span></a></sup><sup id="cite_ref-usingDiskCopy_3-1" class="reference"><a href="#cite_note-usingDiskCopy-3"><span>[</span>3<span>]</span></a></sup></p>
<p>Apple disk images can be created using utilities bundled with Mac OS X, specifically <a href="/wiki/Disk_Copy" title="Disk Copy">Disk Copy</a> in <a href="/wiki/Mac_OS_X_v10.2" title="Mac OS X v10.2">Mac OS X v10.2</a> and earlier and <a href="/wiki/Disk_Utility" title="Disk Utility">Disk Utility</a> in <a href="/wiki/Mac_OS_X_v10.3" title="Mac OS X v10.3" class="mw-redirect">Mac OS X v10.3</a> 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 <a href="/wiki/Command_line_interface" title="Command line interface" class="mw-redirect">command line</a> using the <tt>hdiutil</tt> utility. The format can also be opened by <a href="/wiki/MagicISO" title="MagicISO">MagicISO</a> and the <a href="/wiki/Freeware" title="Freeware">freeware</a> MagicDisc on <a href="/wiki/Microsoft_Windows" title="Microsoft Windows">Microsoft Windows</a>, along with several <a href="/wiki/Free_software" title="Free software">free software</a> implementations<sup class="noprint Inline-Template Template-Fact" style="white-space:nowrap;">[<i><a href="/wiki/Wikipedia:Citation_needed" title="Wikipedia:Citation needed"><span title="This claim needs references to reliable sources. (December 2013)">citation needed</span></a></i>]</sup>.</p>
<h2><span class="mw-headline" id="UDIF_data_format">UDIF data format</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Apple_Disk_Image&amp;action=edit&amp;section=2" title="Edit section: UDIF data format">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<p>Apple disk image files are essentially raw <a href="/wiki/Disk_image" title="Disk image">disk images</a> (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.<sup id="cite_ref-hdiutilman_1-6" class="reference"><a href="#cite_note-hdiutilman-1"><span>[</span>1<span>]</span></a></sup></p>
<p>UDIF supports ADC (an old proprietary compression format by Apple), <a href="/wiki/Zlib" title="Zlib">zlib</a>, and <a href="/wiki/Bzip2" title="Bzip2">bzip2</a> (<a href="/wiki/Mac_OS_X_v10.4" title="Mac OS X v10.4" class="mw-redirect">Mac OS X v10.4</a> and later only) compression internally.</p>
<h3><span class="mw-headline" id="Header">Header</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Apple_Disk_Image&amp;action=edit&amp;section=3" title="Edit section: Header">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
<p>The header can be described using the following C structure. All values are <a href="/wiki/Little-endian" title="Little-endian" class="mw-redirect">little-endian</a> (<b>Apple II</b> byte ordering)</p>
<pre>
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
</pre>
<p>Here is an explanation:</p>
<table class="wikitable">
<tr>
<th>Position(in Hex)</th>
<th>Length (in bytes)</th>
<th>Description</th>
</tr>
<tr>
<td>000</td>
<td>4</td>
<td>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'.</td>
</tr>
<tr>
<td>004</td>
<td>4</td>
<td>A four-character tag identifying the application that created the file.</td>
</tr>
<tr>
<td>008</td>
<td>2</td>
<td>The length of this header, in bytes. Should be 52.</td>
</tr>
<tr>
<td>00A</td>
<td>2</td>
<td>The version number of the image file format. Should be 1.</td>
</tr>
<tr>
<td>00C</td>
<td>4</td>
<td>The image format.</td>
</tr>
<tr>
<td>010</td>
<td>4</td>
<td>Flags</td>
</tr>
<tr>
<td>014</td>
<td>4</td>
<td>The number of 512-byte blocks in the disk image. This value should be zero unless the image format is 1 (ProDOS order).</td>
</tr>
<tr>
<td>018</td>
<td>4</td>
<td>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.</td>
</tr>
<tr>
<td>01C</td>
<td>4</td>
<td>Length of the disk data in bytes. This should be the number of blocks * 512.</td>
</tr>
<tr>
<td>020</td>
<td>4</td>
<td>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).</td>
</tr>
<tr>
<td>024</td>
<td>4</td>
<td>Length of the comment chunk. Zero if there's no comment.</td>
</tr>
<tr>
<td>028</td>
<td>4</td>
<td>Offset to the first byte of the creator-specific data chunk, or zero if there is none.</td>
</tr>
<tr>
<td>02C</td>
<td>4</td>
<td>Length of the creator-specific chunk; zero if there is no creator-specific data.</td>
</tr>
<tr>
<td>030</td>
<td>16</td>
<td>Reserved space; this pads the header to 64 bytes. These values must all be zero.</td>
</tr>
</table>
<h3><span class="mw-headline" id="Image_format_field">Image format field</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Apple_Disk_Image&amp;action=edit&amp;section=4" title="Edit section: Image format field">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
<p>The image format is indicated as one of the following values:</p>
<table class="wikitable">
<tr>
<th>Format</th>
<th>Value</th>
</tr>
<tr>
<td>DOS 3.3 Order</td>
<td>0</td>
</tr>
<tr>
<td>ProDOS Order</td>
<td>1</td>
</tr>
<tr>
<td>Nibblized data</td>
<td>2</td>
</tr>
</table>
<h3><span class="mw-headline" id="Flags">Flags</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Apple_Disk_Image&amp;action=edit&amp;section=5" title="Edit section: Flags">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
<p>The flags field contains bit flags that specify details about the disk image. Bits not defined here must be zero.</p>
<table class="wikitable">
<tr>
<th>Bit</th>
<th>Description</th>
</tr>
<tr>
<td>31</td>
<td>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.</td>
</tr>
<tr>
<td>8</td>
<td>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.</td>
</tr>
<tr>
<td>7-0</td>
<td>The DOS 3.3 volume number, from 0-254, if bit 8 is set. Otherwise these bits should be 0.</td>
</tr>
</table>
<h2><span class="mw-headline" id="Support">Support</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Apple_Disk_Image&amp;action=edit&amp;section=6" title="Edit section: Support">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<h3><span class="mw-headline" id="Macintosh">Macintosh</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Apple_Disk_Image&amp;action=edit&amp;section=7" title="Edit section: Macintosh">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
<p>In <a href="/wiki/Mac_OS_X_v10.2" title="Mac OS X v10.2">Mac OS X v10.2.3</a>, Apple introduced Compressed Disk Images<sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span>[</span>5<span>]</span></a></sup> and Internet-Enabled Disk Images for use with the Apple utility Disk Copy, which was later integrated into <a href="/wiki/Disk_Utility" title="Disk Utility">Disk Utility</a> 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.<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span>[</span>6<span>]</span></a></sup></p>
<p>Currently, the only way to open a <i>.dmg</i> disk image in <a href="/wiki/Mac_OS_9" title="Mac OS 9">Mac OS 9</a> is to use either the developer version of <a href="/wiki/Disk_Copy" title="Disk Copy">Disk Copy</a> (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.<sup class="noprint Inline-Template Template-Fact" style="white-space:nowrap;">[<i><a href="/wiki/Wikipedia:Citation_needed" title="Wikipedia:Citation needed"><span title="This claim needs references to reliable sources. (July 2011)">citation needed</span></a></i>]</sup></p>
<h3><span class="mw-headline" id="Non-Macintosh">Non-Macintosh</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Apple_Disk_Image&amp;action=edit&amp;section=8" title="Edit section: Non-Macintosh">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
<p>Apple has not released any documentation on the format, but attempts to reverse engineer parts of the format have been successful. <a href="/wiki/Free_software" title="Free software">Free software</a> implementations include dmg2img<sup id="cite_ref-dmg2img_7-0" class="reference"><a href="#cite_note-dmg2img-7"><span>[</span>7<span>]</span></a></sup> and DMGExtractor.<sup id="cite_ref-DMGExtractor_8-0" class="reference"><a href="#cite_note-DMGExtractor-8"><span>[</span>8<span>]</span></a></sup></p>
<p>The encrypted layer was reverse engineered in an implementation called VileFault<sup id="cite_ref-VileFault_9-0" class="reference"><a href="#cite_note-VileFault-9"><span>[</span>9<span>]</span></a></sup> (a <a href="/wiki/Spoonerism" title="Spoonerism">spoonerism</a> of <a href="/wiki/FileVault" title="FileVault">FileVault</a>), and dmg2img and DMGExtractor have since implemented support for encrypted images. DMG files can be converted into ISO files using software like PowerISO.<sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span>[</span>10<span>]</span></a></sup><sup id="cite_ref-11" class="reference"><a href="#cite_note-11"><span>[</span>11<span>]</span></a></sup></p>
<p>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.</p>
<p>The well-known cross-platform and <a href="/wiki/GNU_General_Public_License" title="GNU General Public License">GPL</a> licensed format conversion utilities are:<sup class="noprint Inline-Template Template-Fact" style="white-space:nowrap;">[<i><a href="/wiki/Wikipedia:Citation_needed" title="Wikipedia:Citation needed"><span title="This claim needs references to reliable sources. (July 2011)">citation needed</span></a></i>]</sup></p>
<ul>
<li>dmg2img</li>
<li>DMGEXtractor</li>
<li><a href="/wiki/PeaZip" title="PeaZip">PeaZip</a></li>
<li><a href="/wiki/7zip" title="7zip" class="mw-redirect">7zip</a></li>
</ul>
<p>dmg2img<sup id="cite_ref-dmg2img_7-1" class="reference"><a href="#cite_note-dmg2img-7"><span>[</span>7<span>]</span></a></sup> was originally written in <a href="/wiki/Perl" title="Perl">Perl</a>; however, the Perl version is no longer maintained, and the project was rewritten in <a href="/wiki/C_(programming_language)" title="C (programming language)">C</a>. Currently, without additional tools, the resulting images may be mounted only under Mac OS X and under <a href="/wiki/Linux" title="Linux">Linux</a> (provided hfsplus support has been enabled). UDIF ADC-compressed images have been supported since version 1.5.</p>
<p>DMGExtractor<sup id="cite_ref-DMGExtractor_8-1" class="reference"><a href="#cite_note-DMGExtractor-8"><span>[</span>8<span>]</span></a></sup> is written in <a href="/wiki/Java_(programming_language)" title="Java (programming language)">Java</a> with <a href="/wiki/Graphical_user_interface" title="Graphical user interface">GUI</a>, and it supports more advanced features of dmg including AES-128 encrypted images but not UDCO images.</p>
<p>In Windows, most dmg images can be opened using several other programs such as Acute Systems TransMac, HFSExplorer, <a href="/wiki/7-Zip" title="7-Zip">7-Zip</a>, <a href="/wiki/UltraISO" title="UltraISO">UltraISO</a>, and <a href="/wiki/IsoBuster" title="IsoBuster">IsoBuster</a>. MacDrive<sup id="cite_ref-MacDrive_12-0" class="reference"><a href="#cite_note-MacDrive-12"><span>[</span>12<span>]</span></a></sup> can also mount simple dmg files as drives under windows, but not sparse disk or encrypted dmgs.</p>
<p>In Linux and possibly other Unix flavors, most .dmg files can be burned to CD/DVD using any CD-burner program (using <a href="/wiki/Cdrecord" title="Cdrecord" class="mw-redirect">cdrecord</a> directly or a front-end such as K3B or Brasero) or directly mounted to a mountpoint (e.g. <tt>mount -o loop,ro -t hfsplus imagefile.dmg /mnt/mountpoint</tt>).</p>
<p><a href="/wiki/PowerISO" title="PowerISO">PowerISO</a> is a proprietary, cross platform, Freeware CLI tool that runs on <a href="/wiki/Linux" title="Linux">Linux</a>; it can convert most proprietary image formats to ISO, and newer versions support .dmg.</p>
<h2><span class="mw-headline" id="See_also">See also</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Apple_Disk_Image&amp;action=edit&amp;section=9" title="Edit section: See also">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<ul>
<li><a href="/wiki/Cloop" title="Cloop">cloop</a></li>
<li><a href="/wiki/DiskImageMounter" title="DiskImageMounter">DiskImageMounter</a></li>
<li><a href="/wiki/Installer_(Mac_OS_X)" title="Installer (Mac OS X)" class="mw-redirect">Installer (Mac OS X)</a></li>
<li><a href="/wiki/RUNZ" title="RUNZ" class="mw-redirect">RUNZ</a></li>
<li><a href="/wiki/Sparse_image" title="Sparse image">Sparse image</a></li>
</ul>
<h2><span class="mw-headline" id="References">References</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Apple_Disk_Image&amp;action=edit&amp;section=10" title="Edit section: References">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<div class="reflist columns references-column-count references-column-count-2" style="-moz-column-count: 2; -webkit-column-count: 2; column-count: 2; list-style-type: decimal;">
<ol class="references">
<li id="cite_note-hdiutilman-1"><span class="mw-cite-backlink">^ <a href="#cite_ref-hdiutilman_1-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-hdiutilman_1-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-hdiutilman_1-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-hdiutilman_1-3"><sup><i><b>d</b></i></sup></a> <a href="#cite_ref-hdiutilman_1-4"><sup><i><b>e</b></i></sup></a> <a href="#cite_ref-hdiutilman_1-5"><sup><i><b>f</b></i></sup></a> <a href="#cite_ref-hdiutilman_1-6"><sup><i><b>g</b></i></sup></a></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://developer.apple.com/DOCUMENTATION/DARWIN/Reference/ManPages/man1/hdiutil.1.html">"hdiutil man page"</a>. <a rel="nofollow" class="external text" href="http://web.archive.org/web/20081225085455/http://developer.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man1/hdiutil.1.html">Archived</a> from the original on 25 December 2008<span class="reference-accessdate">. Retrieved 2008-11-30</span>.</span><span title="ctx_ver=Z39.88-2004&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AApple+Disk+Image&amp;rft.btitle=hdiutil+man+page&amp;rft.genre=book&amp;rft_id=http%3A%2F%2Fdeveloper.apple.com%2FDOCUMENTATION%2FDARWIN%2FReference%2FManPages%2Fman1%2Fhdiutil.1.html&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;">&#160;</span></span></span></li>
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://support.apple.com/kb/ht4414">"Software Downloads: Formats and Common Error Messages"</a><span class="reference-accessdate">. Retrieved 2009-05-06</span>.</span><span title="ctx_ver=Z39.88-2004&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AApple+Disk+Image&amp;rft.btitle=Software+Downloads%3A+Formats+and+Common+Error+Messages&amp;rft.genre=book&amp;rft_id=http%3A%2F%2Fsupport.apple.com%2Fkb%2Fht4414&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;">&#160;</span></span></span></li>
<li id="cite_note-usingDiskCopy-3"><span class="mw-cite-backlink">^ <a href="#cite_ref-usingDiskCopy_3-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-usingDiskCopy_3-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://support.apple.com/kb/ht1611">"Mac OS X: Using Disk Copy disk image files"</a><span class="reference-accessdate">. Retrieved 2013-04-25</span>.</span><span title="ctx_ver=Z39.88-2004&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AApple+Disk+Image&amp;rft.btitle=Mac+OS+X%3A+Using+Disk+Copy+disk+image+files&amp;rft.genre=book&amp;rft_id=http%3A%2F%2Fsupport.apple.com%2Fkb%2Fht1611&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;">&#160;</span></span></span></li>
<li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://support.apple.com/kb/TA29157?viewlocale=en_US">"DART 1.5.3: Version Change History"</a><span class="reference-accessdate">. Retrieved 2013-04-25</span>.</span><span title="ctx_ver=Z39.88-2004&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AApple+Disk+Image&amp;rft.btitle=DART+1.5.3%3A+Version+Change+History&amp;rft.genre=book&amp;rft_id=http%3A%2F%2Fsupport.apple.com%2Fkb%2FTA29157%3Fviewlocale%3Den_US&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;">&#160;</span></span></span></li>
<li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://lists.apple.com/archives/cocoa-dev/2003/Oct/msg00642.html">"Re: Some apps refuse to launch in 10.2.8! (OT, but very important)"</a>.</span><span title="ctx_ver=Z39.88-2004&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AApple+Disk+Image&amp;rft.btitle=Re%3A+Some+apps+refuse+to+launch+in+10.2.8%21+%28OT%2C+but+very+important%29&amp;rft.genre=book&amp;rft_id=http%3A%2F%2Flists.apple.com%2Farchives%2Fcocoa-dev%2F2003%2FOct%2Fmsg00642.html&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;">&#160;</span></span></span></li>
<li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://developer.apple.com/documentation/DeveloperTools/Conceptual/SoftwareDistribution4/Concepts/sd_disk_images.html">"Guides"</a>. Apple<span class="reference-accessdate">. Retrieved 2010-10-27</span>.</span><span title="ctx_ver=Z39.88-2004&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AApple+Disk+Image&amp;rft.btitle=Guides&amp;rft.genre=book&amp;rft_id=http%3A%2F%2Fdeveloper.apple.com%2Fdocumentation%2FDeveloperTools%2FConceptual%2FSoftwareDistribution4%2FConcepts%2Fsd_disk_images.html&amp;rft.pub=Apple&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;">&#160;</span></span></span></li>
<li id="cite_note-dmg2img-7"><span class="mw-cite-backlink">^ <a href="#cite_ref-dmg2img_7-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-dmg2img_7-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://vu1tur.eu.org/tools/">"dmg2img"</a>. <a rel="nofollow" class="external text" href="http://web.archive.org/web/20101129080913/http://vu1tur.eu.org/tools/">Archived</a> from the original on 29 November 2010<span class="reference-accessdate">. Retrieved 2010-10-27</span>.</span><span title="ctx_ver=Z39.88-2004&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AApple+Disk+Image&amp;rft.btitle=dmg2img&amp;rft.genre=book&amp;rft_id=http%3A%2F%2Fvu1tur.eu.org%2Ftools%2F&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;">&#160;</span></span></span></li>
<li id="cite_note-DMGExtractor-8"><span class="mw-cite-backlink">^ <a href="#cite_ref-DMGExtractor_8-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-DMGExtractor_8-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://www.catacombae.org/dmgx.html">"DMGExtractor"</a><span class="reference-accessdate">. Retrieved 2011-01-03</span>.</span><span title="ctx_ver=Z39.88-2004&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AApple+Disk+Image&amp;rft.btitle=DMGExtractor&amp;rft.genre=book&amp;rft_id=http%3A%2F%2Fwww.catacombae.org%2Fdmgx.html&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;">&#160;</span></span></span></li>
<li id="cite_note-VileFault-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-VileFault_9-0">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://crypto.nsa.org/vilefault/">"VileFault"</a>. 2006-12-29<span class="reference-accessdate">. Retrieved 2010-10-27</span>.</span><span title="ctx_ver=Z39.88-2004&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AApple+Disk+Image&amp;rft.btitle=VileFault&amp;rft.date=2006-12-29&amp;rft.genre=book&amp;rft_id=http%3A%2F%2Fcrypto.nsa.org%2Fvilefault%2F&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;">&#160;</span></span></span></li>
<li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://www.davidtan.org/how-to-convert-dmg-to-iso-on-mac-osx-windows-and-linux/">"How To Convert DMG To ISO in Windows, Linux &amp; Mac"</a>.</span><span title="ctx_ver=Z39.88-2004&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AApple+Disk+Image&amp;rft.btitle=How+To+Convert+DMG+To+ISO+in+Windows%2C+Linux+%26+Mac&amp;rft.genre=book&amp;rft_id=http%3A%2F%2Fwww.davidtan.org%2Fhow-to-convert-dmg-to-iso-on-mac-osx-windows-and-linux%2F&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;">&#160;</span></span></span></li>
<li id="cite_note-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-11">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://hydtech.wordpress.com/2009/01/29/how-to-convert-dmg-files-to-iso-using-poweriso/">"Convert DMG To ISO using PowerISO"</a><span class="reference-accessdate">. Retrieved 2009-02-15</span>.</span><span title="ctx_ver=Z39.88-2004&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AApple+Disk+Image&amp;rft.btitle=Convert+DMG+To+ISO+using+PowerISO&amp;rft.genre=book&amp;rft_id=http%3A%2F%2Fhydtech.wordpress.com%2F2009%2F01%2F29%2Fhow-to-convert-dmg-files-to-iso-using-poweriso%2F&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;">&#160;</span></span></span></li>
<li id="cite_note-MacDrive-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-MacDrive_12-0">^</a></b></span> <span class="reference-text"><span class="citation web">MacDrive Features / Boot Camp / System Requirements /. <a rel="nofollow" class="external text" href="http://www.mediafour.com/products/macdrive/">"MacDrive Home page"</a>. Mediafour. <a rel="nofollow" class="external text" href="http://web.archive.org/web/20101004143511/http://www.mediafour.com/products/macdrive/">Archived</a> from the original on 4 October 2010<span class="reference-accessdate">. Retrieved 2010-10-27</span>.</span><span title="ctx_ver=Z39.88-2004&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AApple+Disk+Image&amp;rft.aulast=MacDrive+Features+%2F+Boot+Camp+%2F+System+Requirements+%2F&amp;rft.au=MacDrive+Features+%2F+Boot+Camp+%2F+System+Requirements+%2F&amp;rft.btitle=MacDrive+Home+page&amp;rft.genre=book&amp;rft_id=http%3A%2F%2Fwww.mediafour.com%2Fproducts%2Fmacdrive%2F&amp;rft.pub=Mediafour&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;">&#160;</span></span></span></li>
</ol>
</div>
<h2><span class="mw-headline" id="External_links">External links</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Apple_Disk_Image&amp;action=edit&amp;section=11" title="Edit section: External links">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<ul>
<li><a rel="nofollow" class="external text" href="http://newosxbook.com/DMG.html">Demystifying DMG</a> A detailed discussion of the DMG file format and mounting it on iOS and Mac OS X</li>
<li><a rel="nofollow" class="external text" href="http://developer.apple.com/documentation/DeveloperTools/Conceptual/SoftwareDistribution/Concepts/sd_disk_images.html">Apple Developer Connection</a> A Quick Look at PackageMaker and Installer</li>
<li><a rel="nofollow" class="external text" href="http://www.macdevcenter.com/pub/a/mac/excerpt/osxph2_1004/?page=2&amp;x-maxdepth=0#chap16">O'Reilly Mac DevCenter</a> Tip 16-5. Create a Disk Image from a Directory in the Terminal</li>
<li><span class="plainlinksneverexpand"><code><a rel="nofollow" class="external text" href="http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/hdiutil.1.html">hdiutil(1)</a></code></span>&#160;&#160;<a href="/wiki/Darwin_(operating_system)" title="Darwin (operating system)">Darwin</a> and <a href="/wiki/Mac_OS_X" title="Mac OS X" class="mw-redirect">Mac OS X</a> General Commands <a href="/wiki/Manual_page_(Unix)" title="Manual page (Unix)" class="mw-redirect">Manual</a></li>
</ul>
<table cellspacing="0" class="navbox" style="border-spacing:0;">
<tr>
<td style="padding:2px;">
<table cellspacing="0" class="nowraplinks hlist collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit;">
<tr>
<th scope="col" class="navbox-title" colspan="2">
<div class="plainlinks hlist navbar mini">
<ul>
<li class="nv-view"><a href="/wiki/Template:Archive_formats" title="Template:Archive formats"><span title="View this template" style=";;background:none transparent;border:none;;">v</span></a></li>
<li class="nv-talk"><a href="/wiki/Template_talk:Archive_formats" title="Template talk:Archive formats"><span title="Discuss this template" style=";;background:none transparent;border:none;;">t</span></a></li>
<li class="nv-edit"><a class="external text" href="//en.wikipedia.org/w/index.php?title=Template:Archive_formats&amp;action=edit"><span title="Edit this template" style=";;background:none transparent;border:none;;">e</span></a></li>
</ul>
</div>
<div style="font-size:110%;"><a href="/wiki/Archive_format" title="Archive format" class="mw-redirect">Archive formats</a></div>
</th>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<th scope="row" class="navbox-group">Archiving only</th>
<td class="navbox-list navbox-odd" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;">
<ul>
<li><a href="/wiki/Ar_(Unix)" title="Ar (Unix)">ar</a></li>
<li><a href="/wiki/Cpio" title="Cpio">cpio</a></li>
<li><a href="/wiki/Shar" title="Shar">shar</a></li>
<li><a href="/wiki/Tar_(computing)" title="Tar (computing)">tar</a></li>
<li><a href="/wiki/LBR_(file_format)" title="LBR (file format)">LBR</a></li>
<li><a href="/wiki/BagIt" title="BagIt">BagIt</a></li>
</ul>
</div>
</td>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<th scope="row" class="navbox-group">Compression only</th>
<td class="navbox-list navbox-even" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;">
<ul>
<li><a href="/wiki/Bzip2" title="Bzip2">bzip2</a></li>
<li><a href="/wiki/Gzip" title="Gzip">gzip</a></li>
<li><a href="/wiki/Lzip" title="Lzip">lzip</a></li>
<li><a href="/wiki/LZMA" title="LZMA" class="mw-redirect">LZMA</a></li>
<li><a href="/wiki/Lzop" title="Lzop">lzop</a></li>
<li><a href="/wiki/Xz" title="Xz">xz</a></li>
<li><a href="/wiki/SQ_(program)" title="SQ (program)">SQ</a></li>
<li><a href="/wiki/Compress" title="Compress">compress</a></li>
</ul>
</div>
</td>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<th scope="row" class="navbox-group">Archiving and compression</th>
<td class="navbox-list navbox-odd" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;">
<ul>
<li><a href="/wiki/7z" title="7z">7z</a></li>
<li><a href="/wiki/ACE_(file_format)" title="ACE (file format)">ACE</a></li>
<li><a href="/wiki/ARC_(file_format)" title="ARC (file format)">ARC</a></li>
<li><a href="/wiki/ARJ" title="ARJ">ARJ</a></li>
<li><a href="/wiki/B1_(archive_format)" title="B1 (archive format)">B1</a></li>
<li><a href="/wiki/Cabinet_(file_format)" title="Cabinet (file format)">Cabinet</a></li>
<li><a href="/wiki/CFS_(file_format)" title="CFS (file format)">cfs</a></li>
<li><a href="/wiki/Compact_Pro" title="Compact Pro">cpt</a></li>
<li><a href="/wiki/DGCA_(Computing)" title="DGCA (Computing)" class="mw-redirect">DGCA</a></li>
<li><strong class="selflink">.dmg</strong></li>
<li><a href="/wiki/EGG_(file_format)" title="EGG (file format)" class="mw-redirect">.egg</a></li>
<li><a href="/wiki/GCA_(file_format)" title="GCA (file format)">GCA</a></li>
<li><a href="/wiki/KGB_Archiver" title="KGB Archiver">kgb</a></li>
<li><a href="/wiki/LHA_(file_format)" title="LHA (file format)">LHA</a></li>
<li><a href="/wiki/LZX_(algorithm)" title="LZX (algorithm)">LZX</a></li>
<li><a href="/wiki/MPQ" title="MPQ">MPQ</a></li>
<li><a href="/wiki/PEA_(file_format)" title="PEA (file format)" class="mw-redirect">PEA</a></li>
<li><a href="/wiki/Quadruple_D" title="Quadruple D">qda</a></li>
<li><a href="/wiki/RAR" title="RAR">RAR</a></li>
<li><a href="/wiki/Rzip" title="Rzip">rzip</a></li>
<li><a href="/wiki/StuffIt" title="StuffIt">sit</a></li>
<li><a href="/wiki/SQX" title="SQX">SQX</a></li>
<li><a href="/wiki/PAQ" title="PAQ">UDA</a></li>
<li><a href="/wiki/UHARC" title="UHARC">UHARC</a></li>
<li><a href="/wiki/Xar_(archiver)" title="Xar (archiver)">Xar</a></li>
<li><a href="/wiki/Zoo_(file_format)" title="Zoo (file format)">zoo</a></li>
<li><a href="/wiki/Zip_(file_format)" title="Zip (file format)">ZIP</a></li>
</ul>
</div>
</td>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<th scope="row" class="navbox-group">Software packaging and distribution</th>
<td class="navbox-list navbox-even" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;">
<ul>
<li><a href="/wiki/APK_(file_format)" title="APK (file format)">APK</a></li>
<li><a href="/w/index.php?title=App_(NeXTStep)&amp;action=edit&amp;redlink=1" class="new" title="App (NeXTStep) (page does not exist)">app</a></li>
<li><a href="/wiki/Deb_(file_format)" title="Deb (file format)">deb</a></li>
<li><a href="/wiki/Installer_(OS_X)" title="Installer (OS X)">pkg (OS X)</a></li>
<li><a href="/wiki/RPM_Package_Manager" title="RPM Package Manager">RPM</a></li>
<li><a href="/wiki/Super_OS#Software_repository" title="Super OS">RUNZ</a></li>
<li><a href="/wiki/Windows_Installer" title="Windows Installer">MSI</a></li>
<li><a href="/wiki/JAR_(file_format)" title="JAR (file format)">JAR</a>
<ul>
<li><small><a href="/wiki/WAR_file_format_(Sun)" title="WAR file format (Sun)" class="mw-redirect">WAR</a></small></li>
<li><small><a href="/wiki/Resource_Adapter" title="Resource Adapter" class="mw-redirect">RAR (Java)</a></small></li>
<li><small><a href="/wiki/EAR_(file_format)" title="EAR (file format)">EAR</a></small></li>
</ul>
</li>
</ul>
</div>
</td>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<th scope="row" class="navbox-group">Document packaging and distribution</th>
<td class="navbox-list navbox-odd" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;">
<ul>
<li><a href="/wiki/Open_eBook" title="Open eBook">OEB Package Format</a></li>
<li><a href="/wiki/EPUB" title="EPUB">OEBPS Container Format</a></li>
<li><a href="/wiki/Open_Packaging_Conventions" title="Open Packaging Conventions">Open Packaging Conventions</a></li>
<li><a href="/wiki/PAQ" title="PAQ">PAQ</a></li>
</ul>
</div>
</td>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<td class="navbox-abovebelow" colspan="2">
<div>
<ul>
<li><img alt="Non-article page" src="//upload.wikimedia.org/wikipedia/en/thumb/8/89/Symbol_neutral_vote.svg/16px-Symbol_neutral_vote.svg.png" width="16" height="16" srcset="//upload.wikimedia.org/wikipedia/en/thumb/8/89/Symbol_neutral_vote.svg/23px-Symbol_neutral_vote.svg.png 1.5x, //upload.wikimedia.org/wikipedia/en/thumb/8/89/Symbol_neutral_vote.svg/31px-Symbol_neutral_vote.svg.png 2x" data-file-width="180" data-file-height="185" /><b><a href="/wiki/Comparison_of_archive_formats" title="Comparison of archive formats">Comparison</a></b>
<ul>
<li><a href="/wiki/File_format#Identifying_the_type_of_a_file" title="File format">type</a></li>
</ul>
</li>
<li><img alt="List-Class article" src="//upload.wikimedia.org/wikipedia/en/thumb/d/db/Symbol_list_class.svg/16px-Symbol_list_class.svg.png" width="16" height="16" srcset="//upload.wikimedia.org/wikipedia/en/thumb/d/db/Symbol_list_class.svg/23px-Symbol_list_class.svg.png 1.5x, //upload.wikimedia.org/wikipedia/en/thumb/d/db/Symbol_list_class.svg/31px-Symbol_list_class.svg.png 2x" data-file-width="180" data-file-height="185" /><b><a href="/wiki/List_of_archive_formats" title="List of archive formats">List</a></b></li>
</ul>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="0" class="navbox" style="border-spacing:0;">
<tr>
<td style="padding:2px;">
<table cellspacing="0" class="nowraplinks collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit;">
<tr>
<th scope="col" class="navbox-title" colspan="2">
<div class="plainlinks hlist navbar mini">
<ul>
<li class="nv-view"><a href="/wiki/Template:Disk_images" title="Template:Disk images"><span title="View this template" style=";;background:none transparent;border:none;;">v</span></a></li>
<li class="nv-talk"><a href="/wiki/Template_talk:Disk_images" title="Template talk:Disk images"><span title="Discuss this template" style=";;background:none transparent;border:none;;">t</span></a></li>
<li class="nv-edit"><a class="external text" href="//en.wikipedia.org/w/index.php?title=Template:Disk_images&amp;action=edit"><span title="Edit this template" style=";;background:none transparent;border:none;;">e</span></a></li>
</ul>
</div>
<div style="font-size:110%;"><a href="/wiki/Disk_image" title="Disk image">Disk image</a> <a href="/wiki/File_format" title="File format">file formats</a></div>
</th>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<th scope="row" class="navbox-group"><a href="/wiki/Optical_discs" title="Optical discs" class="mw-redirect">Optical discs</a></th>
<td class="navbox-list navbox-odd hlist" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;">
<ul>
<li><a href="/wiki/CloneCD_Control_File" title="CloneCD Control File">CCD/IMG/SUB</a></li>
<li><a href="/wiki/Cue_sheet_(computing)" title="Cue sheet (computing)">CUE/BIN</a></li>
<li><a href="/wiki/.CSO" title=".CSO">CSO</a></li>
<li><a href="/wiki/Direct_Access_Archive" title="Direct Access Archive">DAA</a></li>
<li><a href="/wiki/IsoBuster" title="IsoBuster">IBP/IBQ</a></li>
<li><a href="/wiki/ISO_image" title="ISO image">ISO</a></li>
<li><a href="/wiki/UltraISO#ISZ_format" title="UltraISO">ISZ</a></li>
<li><a href="/wiki/Mirror_Disk_File" title="Mirror Disk File" class="mw-redirect">MDS/MDF</a></li>
<li><a href="/wiki/Media_Data_Extended" title="Media Data Extended" class="mw-redirect">MDX</a></li>
<li><a href="/wiki/NRG_(file_format)" title="NRG (file format)">NRG</a></li>
<li><a href="/wiki/MagicISO#Universal_Image_Format" title="MagicISO">UIF</a></li>
</ul>
</div>
</td>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<th scope="row" class="navbox-group"><a href="/wiki/Hard_disks" title="Hard disks" class="mw-redirect">Hard disks</a></th>
<td class="navbox-list navbox-odd hlist" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;">
<ul>
<li><strong class="selflink">DMG</strong></li>
<li><a href="/wiki/Fast_Virtual_Disk" title="Fast Virtual Disk">FVD</a></li>
<li><a href="/wiki/IMG_(file_format)" title="IMG (file format)">IMG</a></li>
<li><a href="/wiki/ISO_image" title="ISO image">ISO</a></li>
<li><a href="/wiki/New_Disk_Image_Format" title="New Disk Image Format" class="mw-redirect">NDIF</a></li>
<li><a href="/wiki/Qcow" title="Qcow">QCOW</a></li>
<li><a href="/wiki/Universal_Disk_Image_Format" title="Universal Disk Image Format" class="mw-redirect">UDIF</a></li>
<li><a href="/wiki/VirtualBox#Virtual_Disk_Image" title="VirtualBox">VDI</a></li>
<li><a href="/wiki/VHD_(file_format)" title="VHD (file format)">VHD</a></li>
<li><a href="/wiki/VMDK" title="VMDK">VMDK</a></li>
<li><a href="/wiki/Windows_Imaging_Format" title="Windows Imaging Format">WIM</a></li>
</ul>
</div>
</td>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<th scope="row" class="navbox-group"><a href="/wiki/Floppy_disks" title="Floppy disks" class="mw-redirect">Floppy disks</a></th>
<td class="navbox-list navbox-even hlist" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;">
<ul>
<li><a href="/wiki/Amiga_Disk_File" title="Amiga Disk File">ADF/ADZ</a></li>
<li><a href="/wiki/Disk_Copy" title="Disk Copy">DC42/DART</a></li>
<li><a href="/wiki/Disk_Copy_Fast" title="Disk Copy Fast">DCF</a></li>
<li><a href="/wiki/Disk_Masher_System" title="Disk Masher System">DMS</a></li>
<li><a href="/wiki/IMG_(file_format)" title="IMG (file format)">IMG/IMA/IMZ</a></li>
<li><a href="/wiki/Virtual_Floppy_Disk_(file_type)" title="Virtual Floppy Disk (file type)" class="mw-redirect">VFD</a></li>
</ul>
</div>
</td>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<th scope="row" class="navbox-group"><a href="/wiki/Flash_drives" title="Flash drives" class="mw-redirect">Flash drives</a></th>
<td class="navbox-list navbox-odd hlist" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;"><a href="/wiki/ISO_image" title="ISO image">ISO</a></div>
</td>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<th scope="row" class="navbox-group"><a href="/wiki/Compact_Disc_Digital_Audio" title="Compact Disc Digital Audio">CD-DA</a></th>
<td class="navbox-list navbox-even hlist" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;"><a href="/wiki/Disc_Description_Protocol" title="Disc Description Protocol">Disc Description Protocol</a></div>
</td>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<td class="navbox-abovebelow" colspan="2">
<div><a href="/wiki/Comparison_of_disc_image_software" title="Comparison of disc image software">Comparison of disc image software</a></div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!--
NewPP limit report
Parsed by mw1081
CPU time usage: 1.008 seconds
Real time usage: 1.090 seconds
Preprocessor visited node count: 1755/1000000
Preprocessor generated node count: 6916/1500000
Postexpand include size: 51524/2048000 bytes
Template argument size: 2251/2048000 bytes
Highest expansion depth: 11/40
Expensive parser function count: 8/500
Lua time usage: 0.140/10.000 seconds
Lua memory usage: 2.96 MB/50 MB
-->
<!-- Saved in parser cache with key enwiki:pcache:idhash:30865034-0!*!0!!en!4!* and timestamp 20140607085319 and revision id 604316924
-->
<noscript><img src="//en.wikipedia.org/wiki/Special:CentralAutoLogin/start?type=1x1" alt="" title="" width="1" height="1" style="border: none; position: absolute;" /></noscript></div> <div class="printfooter">
Retrieved from "<a dir="ltr" href="http://en.wikipedia.org/w/index.php?title=Apple_Disk_Image&amp;oldid=604316924">http://en.wikipedia.org/w/index.php?title=Apple_Disk_Image&amp;oldid=604316924</a>" </div>
<div id='catlinks' class='catlinks'><div id="mw-normal-catlinks" class="mw-normal-catlinks"><a href="/wiki/Help:Category" title="Help:Category">Categories</a>: <ul><li><a href="/wiki/Category:Computer_file_formats" title="Category:Computer file formats">Computer file formats</a></li><li><a href="/wiki/Category:Archive_formats" title="Category:Archive formats">Archive formats</a></li><li><a href="/wiki/Category:OS_X" title="Category:OS X">OS X</a></li><li><a href="/wiki/Category:Disk_images" title="Category:Disk images">Disk images</a></li><li><a href="/wiki/Category:Compression_file_systems" title="Category:Compression file systems">Compression file systems</a></li></ul></div><div id="mw-hidden-catlinks" class="mw-hidden-catlinks mw-hidden-cats-hidden">Hidden categories: <ul><li><a href="/wiki/Category:Articles_lacking_reliable_references_from_July_2011" title="Category:Articles lacking reliable references from July 2011">Articles lacking reliable references from July 2011</a></li><li><a href="/wiki/Category:All_articles_lacking_reliable_references" title="Category:All articles lacking reliable references">All articles lacking reliable references</a></li><li><a href="/wiki/Category:All_articles_with_unsourced_statements" title="Category:All articles with unsourced statements">All articles with unsourced statements</a></li><li><a href="/wiki/Category:Articles_with_unsourced_statements_from_December_2013" title="Category:Articles with unsourced statements from December 2013">Articles with unsourced statements from December 2013</a></li><li><a href="/wiki/Category:Articles_with_unsourced_statements_from_July_2011" title="Category:Articles with unsourced statements from July 2011">Articles with unsourced statements from July 2011</a></li></ul></div></div> <div class="visualClear"></div>
</div>
</div>
<div id="mw-navigation">
<h2>Navigation menu</h2>
<div id="mw-head">
<div id="p-personal" role="navigation" class="" aria-labelledby="p-personal-label">
<h3 id="p-personal-label">Personal tools</h3>
<ul>
<li id="pt-createaccount"><a href="/w/index.php?title=Special:UserLogin&amp;returnto=Apple+Disk+Image&amp;type=signup">Create account</a></li><li id="pt-login"><a href="/w/index.php?title=Special:UserLogin&amp;returnto=Apple+Disk+Image" title="You're encouraged to log in; however, it's not mandatory. [o]" accesskey="o">Log in</a></li> </ul>
</div>
<div id="left-navigation">
<div id="p-namespaces" role="navigation" class="vectorTabs" aria-labelledby="p-namespaces-label">
<h3 id="p-namespaces-label">Namespaces</h3>
<ul>
<li id="ca-nstab-main" class="selected"><span><a href="/wiki/Apple_Disk_Image" title="View the content page [c]" accesskey="c">Article</a></span></li>
<li id="ca-talk"><span><a href="/wiki/Talk:Apple_Disk_Image" title="Discussion about the content page [t]" accesskey="t">Talk</a></span></li>
</ul>
</div>
<div id="p-variants" role="navigation" class="vectorMenu emptyPortlet" aria-labelledby="p-variants-label">
<h3 id="mw-vector-current-variant">
</h3>
<h3 id="p-variants-label"><span>Variants</span><a href="#"></a></h3>
<div class="menu">
<ul>
</ul>
</div>
</div>
</div>
<div id="right-navigation">
<div id="p-views" role="navigation" class="vectorTabs" aria-labelledby="p-views-label">
<h3 id="p-views-label">Views</h3>
<ul>
<li id="ca-view" class="selected"><span><a href="/wiki/Apple_Disk_Image" >Read</a></span></li>
<li id="ca-edit"><span><a href="/w/index.php?title=Apple_Disk_Image&amp;action=edit" title="You can edit this page. Please use the preview button before saving [e]" accesskey="e">Edit</a></span></li>
<li id="ca-history" class="collapsible"><span><a href="/w/index.php?title=Apple_Disk_Image&amp;action=history" title="Past versions of this page [h]" accesskey="h">View history</a></span></li>
</ul>
</div>
<div id="p-cactions" role="navigation" class="vectorMenu emptyPortlet" aria-labelledby="p-cactions-label">
<h3 id="p-cactions-label"><span>Actions</span><a href="#"></a></h3>
<div class="menu">
<ul>
</ul>
</div>
</div>
<div id="p-search" role="search">
<h3>
<label for="searchInput">Search</label>
</h3>
<form action="/w/index.php" id="searchform">
<div id="simpleSearch">
<input type="search" name="search" placeholder="Search" title="Search Wikipedia [f]" accesskey="f" id="searchInput" /><input type="hidden" value="Special:Search" name="title" /><input type="submit" name="fulltext" value="Search" title="Search Wikipedia for this text" id="mw-searchButton" class="searchButton mw-fallbackSearchButton" /><input type="submit" name="go" value="Go" title="Go to a page with this exact name if one exists" id="searchButton" class="searchButton" /> </div>
</form>
</div>
</div>
</div>
<div id="mw-panel">
<div id="p-logo" role="banner"><a style="background-image: url(//upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png);" href="/wiki/Main_Page" title="Visit the main page"></a></div>
<div class="portal" role="navigation" id='p-navigation' aria-labelledby='p-navigation-label'>
<h3 id='p-navigation-label'>Navigation</h3>
<div class="body">
<ul>
<li id="n-mainpage-description"><a href="/wiki/Main_Page" title="Visit the main page [z]" accesskey="z">Main page</a></li>
<li id="n-contents"><a href="/wiki/Portal:Contents" title="Guides to browsing Wikipedia">Contents</a></li>
<li id="n-featuredcontent"><a href="/wiki/Portal:Featured_content" title="Featured content the best of Wikipedia">Featured content</a></li>
<li id="n-currentevents"><a href="/wiki/Portal:Current_events" title="Find background information on current events">Current events</a></li>
<li id="n-randompage"><a href="/wiki/Special:Random" title="Load a random article [x]" accesskey="x">Random article</a></li>
<li id="n-sitesupport"><a href="https://donate.wikimedia.org/wiki/Special:FundraiserRedirector?utm_source=donate&amp;utm_medium=sidebar&amp;utm_campaign=C13_en.wikipedia.org&amp;uselang=en" title="Support us">Donate to Wikipedia</a></li>
<li id="n-shoplink"><a href="//shop.wikimedia.org" title="Visit the Wikimedia Shop">Wikimedia Shop</a></li>
</ul>
</div>
</div>
<div class="portal" role="navigation" id='p-interaction' aria-labelledby='p-interaction-label'>
<h3 id='p-interaction-label'>Interaction</h3>
<div class="body">
<ul>
<li id="n-help"><a href="/wiki/Help:Contents" title="Guidance on how to use and edit Wikipedia">Help</a></li>
<li id="n-aboutsite"><a href="/wiki/Wikipedia:About" title="Find out about Wikipedia">About Wikipedia</a></li>
<li id="n-portal"><a href="/wiki/Wikipedia:Community_portal" title="About the project, what you can do, where to find things">Community portal</a></li>
<li id="n-recentchanges"><a href="/wiki/Special:RecentChanges" title="A list of recent changes in the wiki [r]" accesskey="r">Recent changes</a></li>
<li id="n-contactpage"><a href="//en.wikipedia.org/wiki/Wikipedia:Contact_us">Contact page</a></li>
</ul>
</div>
</div>
<div class="portal" role="navigation" id='p-tb' aria-labelledby='p-tb-label'>
<h3 id='p-tb-label'>Tools</h3>
<div class="body">
<ul>
<li id="t-whatlinkshere"><a href="/wiki/Special:WhatLinksHere/Apple_Disk_Image" title="List of all English Wikipedia pages containing links to this page [j]" accesskey="j">What links here</a></li>
<li id="t-recentchangeslinked"><a href="/wiki/Special:RecentChangesLinked/Apple_Disk_Image" title="Recent changes in pages linked from this page [k]" accesskey="k">Related changes</a></li>
<li id="t-upload"><a href="/wiki/Wikipedia:File_Upload_Wizard" title="Upload files [u]" accesskey="u">Upload file</a></li>
<li id="t-specialpages"><a href="/wiki/Special:SpecialPages" title="A list of all special pages [q]" accesskey="q">Special pages</a></li>
<li id="t-permalink"><a href="/w/index.php?title=Apple_Disk_Image&amp;oldid=604316924" title="Permanent link to this revision of the page">Permanent link</a></li>
<li id="t-info"><a href="/w/index.php?title=Apple_Disk_Image&amp;action=info">Page information</a></li>
<li id="t-wikibase"><a href="//www.wikidata.org/wiki/Q1228757" title="Link to connected data repository item [g]" accesskey="g">Data item</a></li>
<li id="t-cite"><a href="/w/index.php?title=Special:Cite&amp;page=Apple_Disk_Image&amp;id=604316924" title="Information on how to cite this page">Cite this page</a></li> </ul>
</div>
</div>
<div class="portal" role="navigation" id='p-coll-print_export' aria-labelledby='p-coll-print_export-label'>
<h3 id='p-coll-print_export-label'>Print/export</h3>
<div class="body">
<ul>
<li id="coll-create_a_book"><a href="/w/index.php?title=Special:Book&amp;bookcmd=book_creator&amp;referer=Apple+Disk+Image">Create a book</a></li>
<li id="coll-download-as-rl"><a href="/w/index.php?title=Special:Book&amp;bookcmd=render_article&amp;arttitle=Apple+Disk+Image&amp;oldid=604316924&amp;writer=rl">Download as PDF</a></li>
<li id="t-print"><a href="/w/index.php?title=Apple_Disk_Image&amp;printable=yes" title="Printable version of this page [p]" accesskey="p">Printable version</a></li>
</ul>
</div>
</div>
<div class="portal" role="navigation" id='p-lang' aria-labelledby='p-lang-label'>
<h3 id='p-lang-label'>Languages</h3>
<div class="body">
<ul>
<li class="interlanguage-link interwiki-ar"><a href="//ar.wikipedia.org/wiki/%D8%B5%D9%88%D8%B1%D8%A9_%D9%82%D8%B1%D8%B5_%D8%A3%D8%A8%D9%84" title="صورة قرص أبل Arabic" lang="ar" hreflang="ar">العربية</a></li>
<li class="interlanguage-link interwiki-cs"><a href="//cs.wikipedia.org/wiki/DMG" title="DMG Czech" lang="cs" hreflang="cs">Čeština</a></li>
<li class="interlanguage-link interwiki-de"><a href="//de.wikipedia.org/wiki/Disk-Image-Datei" title="Disk-Image-Datei German" lang="de" hreflang="de">Deutsch</a></li>
<li class="interlanguage-link interwiki-it"><a href="//it.wikipedia.org/wiki/Apple_disk_image" title="Apple disk image Italian" lang="it" hreflang="it">Italiano</a></li>
<li class="interlanguage-link interwiki-nl"><a href="//nl.wikipedia.org/wiki/Apple_Disk_Image" title="Apple Disk Image Dutch" lang="nl" hreflang="nl">Nederlands</a></li>
<li class="interlanguage-link interwiki-pt"><a href="//pt.wikipedia.org/wiki/.dmg" title=".dmg Portuguese" lang="pt" hreflang="pt">Português</a></li>
<li class="interlanguage-link interwiki-sk"><a href="//sk.wikipedia.org/wiki/.dmg" title=".dmg Slovak" lang="sk" hreflang="sk">Slovenčina</a></li>
<li class="interlanguage-link interwiki-sv"><a href="//sv.wikipedia.org/wiki/.dmg" title=".dmg Swedish" lang="sv" hreflang="sv">Svenska</a></li>
<li class="uls-p-lang-dummy"><a href="#"></a></li>
</ul>
<div class='after-portlet after-portlet-lang'><span class="wb-langlinks-edit wb-langlinks-link"><a action="edit" href="//www.wikidata.org/wiki/Q1228757#sitelinks-wikipedia" text="Edit links" title="Edit interlanguage links" class="wbc-editpage">Edit links</a></span></div> </div>
</div>
</div>
</div>
<div id="footer" role="contentinfo">
<ul id="footer-info">
<li id="footer-info-lastmod"> This page was last modified on 15 April 2014 at 15:49.<br /></li>
<li id="footer-info-copyright">Text is available under the <a rel="license" href="//en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License">Creative Commons Attribution-ShareAlike License</a><a rel="license" href="//creativecommons.org/licenses/by-sa/3.0/" style="display:none;"></a>;
additional terms may apply. By using this site, you agree to the <a href="//wikimediafoundation.org/wiki/Terms_of_Use">Terms of Use</a> and <a href="//wikimediafoundation.org/wiki/Privacy_policy">Privacy Policy</a>. Wikipedia® is a registered trademark of the <a href="//www.wikimediafoundation.org/">Wikimedia Foundation, Inc.</a>, a non-profit organization.</li>
</ul>
<ul id="footer-places">
<li id="footer-places-privacy"><a href="//wikimediafoundation.org/wiki/Privacy_policy" title="wikimedia:Privacy policy">Privacy policy</a></li>
<li id="footer-places-about"><a href="/wiki/Wikipedia:About" title="Wikipedia:About">About Wikipedia</a></li>
<li id="footer-places-disclaimer"><a href="/wiki/Wikipedia:General_disclaimer" title="Wikipedia:General disclaimer">Disclaimers</a></li>
<li id="footer-places-contact"><a href="//en.wikipedia.org/wiki/Wikipedia:Contact_us">Contact Wikipedia</a></li>
<li id="footer-places-developers"><a href="https://www.mediawiki.org/wiki/Special:MyLanguage/How_to_contribute">Developers</a></li>
<li id="footer-places-mobileview"><a href="//en.m.wikipedia.org/wiki/Apple_Disk_Image" class="noprint stopMobileRedirectToggle">Mobile view</a></li>
</ul>
<ul id="footer-icons" class="noprint">
<li id="footer-copyrightico">
<a href="//wikimediafoundation.org/"><img src="//bits.wikimedia.org/images/wikimedia-button.png" width="88" height="31" alt="Wikimedia Foundation"/></a>
</li>
<li id="footer-poweredbyico">
<a href="//www.mediawiki.org/"><img src="//bits.wikimedia.org/static-1.24wmf7/skins/common/images/poweredby_mediawiki_88x31.png" alt="Powered by MediaWiki" width="88" height="31" /></a>
</li>
</ul>
<div style="clear:both"></div>
</div>
<script>/*<![CDATA[*/window.jQuery && jQuery.ready();/*]]>*/</script><script>if(window.mw){
mw.loader.state({"site":"loading","user":"ready","user.groups":"ready"});
}</script>
<script>if(window.mw){
mw.loader.load(["ext.cite","mediawiki.toc","mobile.desktop","mediawiki.action.view.postEdit","mediawiki.user","mediawiki.hidpi","mediawiki.page.ready","mediawiki.searchSuggest","ext.gadget.teahouse","ext.gadget.ReferenceTooltips","ext.gadget.DRN-wizard","ext.gadget.charinsert","ext.gadget.refToolbar","mw.MwEmbedSupport.style","mmv.bootstrap.autostart","ext.gettingstarted.assignToken","ext.eventLogging.subscriber","ext.navigationTiming","schema.UniversalLanguageSelector","ext.uls.eventlogger","ext.uls.interlanguage"],null,true);
}</script>
<script src="//bits.wikimedia.org/en.wikipedia.org/load.php?debug=false&amp;lang=en&amp;modules=site&amp;only=scripts&amp;skin=vector&amp;*"></script>
<script>if(window.mw){
mw.config.set({"wgBackendResponseTime":189,"wgHostname":"mw1180"});
}</script>
</body>
</html>

503
DMG.html Normal file
View File

@@ -0,0 +1,503 @@
<!DOCTYPE html>
<html>
<head>
<title>DeMystifyinG the DMG file format</title>
<style>
.output { padding-left : 10px; padding-right: 10px; padding-top: 5px; padding-bottom : 5px; border : 1px solid black; width : 90%; background-color : black ; color : #00FF00; }
.typed { color : white }
.listing { padding-left : 10px; padding-right : 10px; padding-top: 2px; padding-bottom : 2px;overflow : auto;background-color : #ddebda; margin-left :auto; margin-right : auto; width : 90%}
.superscript { color : red ;vertical-align : super; font-size : 8pt; }
.note { border : 1px solid red; padding : 10px; width: 50%; margin-left: auto; margin-right : auto; background-color : yellow; box-shadow : 5px 5px 2px #888;}
.boxed { border : 1px solid black; padding : 2px;}
figcaption { border-top : 1px solid white; margin-top : 10px; color : white; margin-left: auto; margin-right: auto; font-size : smaller;}
.listingCaption { border-top : 1px solid black; color : black;}
figure { border : 1px solid black ; padding: 5px; }
article { width : 80% ; margin-left : auto ; margin-right : auto;}
.boxeDiv { margin-left : auto; margin-right : auto; border : 1px solid black; background : silver; color : black; padding : 10px; width : 60%; margin-top : 20px; margin-bottom : 20px; box-shadow: 10px 10px 5px #888;}
h1 { margin-left: auto; margin-right : auto}
</style>
</head>
<body>
<article>
<h1>Demystifying the DMG File Format</h1>
<h4>Jonathan Levin, http://newosxbook.com/ - 6/12/13</h4>
<section>
<h2>1. About</h2>
As part of writing HFSleuth, a "bonus" tool for my book, I decided to implement DMG (disk image support). I realized, however, that the DMG file format (being Apple proprietary) was woefully undocumented. I briefly mention DMGs (pages 589-590), but due to the page constraints of an already large book, I had failed to delve into their format sufficiently. This article, therefore, is an attempt to rectify that shortcoming. The DMG file format has been painstakingly reverse-engineered by several<span class="superscript">[<a href="#ref1">1</a>,<a href="#ref2">2</a>]</span>, and this article/addendum aims to consolidate their hard work into a single document. HFSleuth can operate fully on all known DMG types (to date), and can serve as a complementary tool to Apple's hdiutil(1), or - as it is POSIX portable - even as a replacement for it, on non OS X systems. When set to verbose mode, HFSleuth also provides step by step information as it processes DMGs, and is used in the examples below.
</section>
<section>
<h2>2. The Disk Image file format</h2>
The first noteable fact about the DMG file format is, that there is no DMG file format. DMGs come in a variety of sub-formats, corresponding to the different tools which create them, and their compression schemes. The common denominator of most of these is the existence of a 512-byte trailer at the end of the file. This trailer is identifiable by a magic 32-bit value, 0x6B6F6C79, which is "koly" in ASCII. As other references to this trailer call it the "koly" block, we can do the same. Note, that "most" is not "all": images created with hdiutil(1), for example, can simply be raw dd(1)-like images of the disk layout, with no metadata. In those cases, however, there is nothing special or noteworthy about the file, which can be read as any disk would, by its partition table (commonly APM, or GPT). Images created with the DiscRecording.Framework contain the koly block.
The koly block, when present, is formatted according to the following:
<figure class="listing">
<pre>
<code>
typedef struct {
char Signature[4]; // Magic ('koly')
uint32_t Version; // Current version is 4
uint32_t HeaderSize; // sizeof(this), always 512
uint32_t Flags; // Flags
uint64_t RunningDataForkOffset; //
uint64_t DataForkOffset; // Data fork offset (usually 0, beginning of file)
uint64_t DataForkLength; // Size of data fork (usually up to the XMLOffset, below)
uint64_t RsrcForkOffset; // Resource fork offset, if any
uint64_t RsrcForkLength; // Resource fork length, if any
uint32_t SegmentNumber; // Usually 1, may be 0
uint32_t SegmentCount; // Usually 1, may be 0
uuid_t SegmentID; // 128-bit GUID identifier of segment (if SegmentNumber !=0)
uint32_t DataChecksumType; // Data fork
uint32_t DataChecksumSize; // Checksum Information
uint32_t DataChecksum[32]; // Up to 128-bytes (32 x 4) of checksum
uint64_t XMLOffset; // Offset of property list in DMG, from beginning
uint64_t XMLLength; // Length of property list
uint8_t Reserved1[120]; // 120 reserved bytes - zeroed
uint32_t ChecksumType; // Master
uint32_t ChecksumSize; // Checksum information
uint32_t Checksum[32]; // Up to 128-bytes (32 x 4) of checksum
uint32_t ImageVariant; // Commonly 1
uint64_t SectorCount; // Size of DMG when expanded, in sectors
uint32_t reserved2; // 0
uint32_t reserved3; // 0
uint32_t reserved4; // 0
} __attribute__((__packed__)) UDIFResourceFile;
</code>
</pre>
<figcaption class="listingCaption">Listing 1: The koly block format</figcaption>
</figure>
<div class="note">
Note: All fields in the koly block (and, in fact, elsewhere in the DMG format) are in big endian ordering. This is to preserve compatibility with older generations of OS X, which were PPC-based. This requires DMG implementations to use macros such as be##_to_cpu (16, 32, and 64).
</div>
<br/>
The most important elements in the koly block are the fields pointing to the XML plist: This property list, embedded elsewhere in the DMG, contains the DMG block map table. Commonly, the plist is placed in the blocks leading up to the koly block, which fits the simple algorithm to create a DMG: First compress the image blocks, then place the XML plist, and finalize with the koly block. This is shown in figure 1:
<figure>
<table class="boxed">
<tr><td class="boxed"><br/><br/>The Data Fork:<br/>Disk blocks, compressed in various ways <br/><br/><br/>...<br/></td></tr>
<tr><td class="boxed" >XML property list (variable)</td></tr>
<tr><td class="boxed" >koly trailer (512 bytes)</td></tr>
</table>
<figcaption>Figure 1: The DMG file format</figcaption>
</figure>
Using HFSleuth in verbose mode on a DMG will dump the KOLY header, as shown in the following output:
<figure class="output">
<pre>
<code>
<span class="prompt">HFSleuth&gt; </span><span class="typed">ver</span>
Verbose output is on
<span class="prompt">HFSleuth&gt; </span><span class="typed">fs iTunes11.dmg</span>
KOLY header found at 200363895:
UDIF version 4, Header Size: 512
Flags:1
Rsrc fork: None
Data fork: from 0, spanning 200307220 bytes
XML plist: from 200307220, spanning 56675 bytes (to 200363895)
Segment #: 1, Count: 1
Segment UUID: 626f726e-7743259b-6086eb93-4b42fb65
Running Data fork offset 0
Sectors: 1022244
</code>
</pre>
<figcaption>Output 1: Using HFSleuth on the iTunes 11.0 DMG</figcaption>
</figure>
<br/>
This method of creating DMGs also explains why commands such as "file" have a hard time identifying the DMG file type: In the absence of a fixed header, a DMG can start with any type of data (disk or partition headers), which can be further compressed by myriad means. DMG files compressed with BZlib, for example, start with a BZ2 header. They cannot be opened with bunzip2, however, since compression methods are intermingled, and bunzip2 will discard blocks which do not start with a bz2 header.
<br/>
<figure class="output">
<code>
<span class="prompt">root@Erudite (/tmp)# </span><span class="typed">file DMG/install_flash_player_osx.dmg </span><br/>
DMG/install_flash_player_osx.dmg: bzip2 compressed data, block size = 100k<br/>
<span class="prompt">root@Erudite (/tmp)# </span><span class="typed">hdiutil imageinfo DMG/install_flash_player_osx.dmg | grep Format</span><br/>
Format Description: UDIF read-only compressed (bzip2)<br/>
Format: UDBZ
<br/>
</code>
<figcaption>Output 2: a BZ2-compressed DMG</figcaption>
</figure>
DMGs compressed with zlib often incorrectly appear as "VAX COFF", due to the zlib header.
<figure class="output">
<code>
<span class="prompt">root@Erudite (/tmp)# </span><span class="typed">file DMG/xcode46.dmg </span><br/><br/>
DMG/xcode46.dmg: VAX COFF executable not stripped - version 376<br/>
<span class="prompt">root@Erudite (/tmp)# </span><span class="typed">hdiutil imageinfo DMG/xcode46.dmg | grep Format</span><br/>
Format Description: UDIF read-only compressed (zlib)<br/>
Format: UDZO
<br/>
</code>
<figcaption>Output 3: a zLib-compressed DMG</figcaption>
</figure>
The XML Property list (which is uncompressed and easily viewable by seeking to the DOCTYPE declaration using more(1) or using tail(1)) is technically the resource fork of the DMG. The property list file contains, at a minimum, a "blkx" key, though it may contain other key/values, most commonly "plst", and sometimes a service level agreement (SLA) which will be displayed by the OS (specifically, /System/Library/PrivateFrameworks/DiskImages.framework/Versions/A/Resources/DiskImages UI Agent.app/Contents/MacOS/DiskImages UI Agent) as a pre-requisite to attaching the DMG<span class="superscript"><a href="#footnote1">*</a></span>.
Due to XML parser restrictions, data in the property list is 7-bit. This forces all binary (8-bit) data to be encoded using Base-64 encoding (a wiser choice would have been using CDATA blocks). The output of such a property list is shown below:
<figure class="listing">
<pre>
<code>
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
&lt;key&gt;resource-fork&lt;/key&gt;
&lt;dict&gt;
&lt;key&gt;blkx&lt;/key&gt;
&lt;array&gt;
&lt;dict&gt;
&lt;key&gt;Attributes&lt;/key&gt;
&lt;string&gt;0x0050&lt;/string&gt;
&lt;key&gt;CFName&lt;/key&gt;
&lt;string&gt;Driver Descriptor Map (DDM : 0)&lt;/string&gt;
&lt;key&gt;Data&lt;/key&gt;
&lt;data&gt;
bWlzaAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAA
AAIB/////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAIAAAAg6P2c0P9/AAAwGb9f/38AAAAAAAAAAAAAwBi/
X/9/AAAoAAAAAAAAAAAAAAAAAAAAAKAFAAEAAAAYAAAA
AAAAACAkv1//fwAA8Bi/X/9/AACKWZeI/38AACAZv1//
fwAAKAAAAAAAAAAAAAAAAAAAAFhAAgEBAAAAABm/X/9/
AAAAAAACgAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAA
AAAAAAAAAAAAAAAAOP////8AAAAAAAAAAAAAAAEAAAAA
AAAAAAAAAAAAAAA4AAAAAAAAAAA=
&lt;/data&gt;
&lt;key&gt;ID&lt;/key&gt;
&lt;string&gt;-1&lt;/string&gt;
&lt;key&gt;Name&lt;/key&gt;
&lt;string&gt;Driver Descriptor Map (DDM : 0)&lt;/string&gt;
&lt;/dict&gt;
&lt;dict&gt;
&lt;key&gt;Attributes&lt;/key&gt;
&lt;string&gt;0x0050&lt;/string&gt;
&lt;key&gt;CFName&lt;/key&gt;
&lt;string&gt;Apple (Apple_partition_map : 1)&lt;/string&gt;
&lt;key&gt;Data&lt;/key&gt;
&lt;data&gt;
bWlzaAAAAAEAAAAAAAAAAQAAAAAAAAA/AAAAAAAAAAAA
AAIBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAIAAAAgk1UtLv9/AAAwGb9f/38AAAAAAAAAAAAAwBi/
X/9/AAAoAAAAAAAAAAAAAAAAAAAAAKAFAAEAAAAYAAAA
AAAAACAkv1//fwAA8Bi/X/9/AACKWZeI/38AACAZv1//
fwAAKAAAAAAAAAAAAAAAAAAAAFhAAgEBAAAAABm/X/9/
AAAAAAACgAAABgAAAAAAAAAAAAAAAAAAAAAAAAA/AAAA
AAAAADgAAAAAAAAAu/////8AAAAAAAAAAAAAAD8AAAAA
AAAAAAAAAAAAAADzAAAAAAAAAAA=
&lt;/data&gt;
&lt;key&gt;ID&lt;/key&gt;
&lt;string&gt;0&lt;/string&gt;
&lt;key&gt;Name&lt;/key&gt;
&lt;string&gt;Apple (Apple_partition_map : 1)&lt;/string&gt;
&lt;/dict&gt;
&lt;dict&gt;
&lt;key&gt;Attributes&lt;/key&gt;
&lt;string&gt;0x0050&lt;/string&gt;
&lt;key&gt;CFName&lt;/key&gt;
&lt;string&gt;DiscRecording 5.0.9d2 (Apple_HFS : 2)&lt;/string&gt;
&lt;key&gt;Data&lt;/key&gt;
&lt;data&gt;
bWlzaAAAAAEAAAAAAAAAQAAAAAAAAIRcAAAAAAAAAAAA
AAQEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAIAAAAgbcaqTv9/AAAwGb9f/38AAAAAAAAAAAAAwBi/
X/9/AAAoAAAAAAAAAAAAAAAAAAAAAKAFAAEAAAAYAAAA
...
</code>
</pre>
<figcaption class="listingCaption">Listing 2: Sample XML plist in an APM formatted DMG (Flash installer)</figcaption>
</figure>
A detailed discussion of both APM and GPT can be found in chapter 15 of the book<span class="superscript">[3]</span>, as well as Apple's notes on APM<span class="superscript">[4]</span> and GPT<span class="superscript">[5]</span>. What makes the blxx data useful, however, is that it allows an implementation to <i>skip past</i> the partition table data, and isolate the partition of interest directly from the DMG.
The "data" in the blxx header is a structure, which (like its sibling, koly) is also identifiable by a fixed signature - in this case "mish". In Base-64 this encodes as "bWlza", which is readily evident in the previous listing. The mish block is formatted like this:
<figure class="listing">
<pre>
<code>
typedef struct {
uint32_t Signature; // Magic ('mish')
uint32_t Version; // Current version is 1
uint64_t SectorNumber; // Starting disk sector in this blkx descriptor
uint64_t SectorCount; // Number of disk sectors in this blkx descriptor
uint64_t DataOffset;
uint32_t BuffersNeeded;
uint32_t BlockDescriptors; // Number of descriptors
uint32_t reserved1;
uint32_t reserved2;
uint32_t reserved3;
uint32_t reserved4;
uint32_t reserved5;
uint32_t reserved6;
UDIFChecksum checksum;
uint32_t NumberOfBlockChunks;
BLKXChunkEntry [0];
} __attribute__((__packed__)) BLKXTable;
// Where each BLXKRunEntry is defined as follows:
typedef struct {
uint32_t EntryType; // Compression type used or entry type (see next table)
uint32_t Comment; // "+beg" or "+end", if EntryType is comment (0x7FFFFFFE). Else reserved.
uint64_t SectorNumber; // Start sector of this chunk
uint64_t SectorCount; // Number of sectors in this chunk
uint64_t CompressedOffset; // Start of chunk in data fork
uint64_t CompressedLength; // Count of bytes of chunk, in data fork
} __attribute__((__packed__)) BLKXChunkEntry;
</code>
</pre>
<figcaption class="listingCaption">Listing 3: The mish block format</figcaption>
</figure>
In other words, for each entry, the chunk of <i>SectorCount</i> sectors, starting at <i>SectorNumber</i> are stored at <i>CompressedLength</i> bytes, at offset <i>CompressedOffset</i> in the data fork. When expanded, each such chunk will take <i>SectorCount * SECTOR_SIZE</i> bytes. Each chunk of blocks in a given entry is stored using the same compression, but different entries can contain different compression methods.
<div class="boxeDiv">
Question:
What are two advantages of breaking the image into block chunks, as described above? (Answer at end of document)
</div>
The various block chunk entry types are shown below:
<figure>
<table>
<caption>Table: DMG blxx types</caption>
<thead>
<tr>
<th>Type</th>
<th>Scheme</th>
<th>Meaning</th>
</tr>
<tbody>
<tr><td>0x00000000</td><td>---</td><td>Zero-Fill</td></tr>
<tr><td>0x00000001</td><td>UDRW/UDRO</td><td>RAW or NULL compression (uncompressed)</td></tr>
<tr><td>0x00000002</td><td>--- </td><td>Ignored/unknown</td></tr>
<tr><td>0x80000004</td><td>UDCO </td><td>Apple Data Compression (ADC)</td></tr>
<tr><td>0x80000005</td><td>UDZO </td><td>zLib data compression</td></tr>
<tr><td>0x80000006</td><td>UDBZ </td><td>bz2lib data compression</td></tr>
<tr><td>0x7ffffffe</td><td>--- </td><td>No blocks - Comment: +beg and +end</td></tr>
<tr><td>0xffffffff</td><td>--- </td><td>No blocks - Identifies last blxx entry</td></tr>
</tbody>
</table>
</figure>
Running HFSleuth on a DMG in verbose and debug mode will produce detailed output of the decompression, demonstrating the above:
<figure class="output">
<code>
<span class="typed">
..
</span>
<br/>
Decompressing 0x345 blocks, Desc 4<br/>
1022160 sectors - 523345920 bytes<br/>
Blk 0 - 0 (512 sectors) - Compressed to 397, 1407 bytes Zlib <br/>
Blk 1 - 512 (512 sectors) - Compressed to 1804, 1167 bytes Zlib<br/>
Blk 2 - 1024 (512 sectors) - Compressed to 2971, 1167 bytes Zlib<br/>
Blk 3 - 1536 (512 sectors) - Compressed to 4138, 1167 bytes Zlib<br/>
Blk 4 - 2048 (512 sectors) - Compressed to 5305, 1167 bytes Zlib<br/>
Blk 5 - 2560 (512 sectors) - Compressed to 6472, 1167 bytes Zlib<br/>
Blk 6 - 3072 (512 sectors) - Compressed to 7639, 1167 bytes Zlib<br/>
Blk 7 - 3584 (512 sectors) - Compressed to 8806, 1167 bytes Zlib<br/>
Blk 8 - 4096 (512 sectors) - Compressed to 9973, 1167 bytes Zlib<br/>
...<br/>
Blk 39 - 19968 (512 sectors) - Compressed to 46202, 1167 bytes Zlib<br/>
Blk 40 - 20480 (216 sectors) - Compressed to 47369, 506 bytes Zlib<br/>
Blk 41 - 20696 (103200 sectors) - Compressed to 47875, 0 bytes IGNORE # zeroed/unused sectors <br/>
Blk 42 - 123896 (512 sectors) - Compressed to 47875, 7904 bytes Zlib<br/>
Blk 43 - 124408 (512 sectors) - Compressed to 55779, 1167 bytes Zlib<br/>
...<br/>
Blk 828 - 1019624 (512 sectors) - Compressed to 199079734, 250792 bytes Zlib<br/>
Blk 829 - 1020136 (512 sectors) - Compressed to 199330526, 262144 bytes RAW # Note 262,144 = 512 * 512<br/>
Blk 830 - 1020648 (512 sectors) - Compressed to 199592670, 230554 bytes Zlib<br/>
Blk 831 - 1021160 (512 sectors) - Compressed to 199823224, 238101 bytes Zlib<br/>
Blk 832 - 1021672 (480 sectors) - Compressed to 200061325, 245760 bytes RAW # Note 245,760 = 480 * 512<br/>
Blk 833 - 1022152 (6 sectors) - Compressed to 200307085, 0 bytes IGNORE<br/>
Blk 834 - 1022158 (1 sectors) - Compressed to 200307085, 135 bytes Zlib<br/>
Blk 835 - 1022159 (1 sectors) - Compressed to 200307220, 0 bytes IGNORE<br/>
Blk 836 - 1022160 (0 sectors) - Compressed to 200307220, 0 bytes Terminator<br/>
decompression done<br/>
<figcaption>Output 4: Decompressing a DMG image in HFSleuth, debug mode</figcaption>
</code>
</figure>
Note in the example above the mix of Zlib and RAW compression methods: Zlib uses highly efficient compression algorithms, but sometimes it just makes sense to leave data in raw form (e.g. chunks 829 and 832). In these cases, the "compressed" size is actually the same as the uncompressed size. It's also worth noting that (though it is commonly the case) there is no guarantee that the blocks are compressed in order.
</section>
<section>
<h2>3. Mounting DMGs</h2>
DMGs can be mounted, just like any other file system, though technically this is what is known as a "loopback" mount (i.e. a mount backed by a local file, rather than a device file). To mount a DMG, the system uses the DiskImages kernel extension (KExt), also known as the IOHDIXController.kext. This is clearly visible in both OS X and iOS, using kextstat (or jkextstat, in the latter):
<figure class="output">
<pre>
<output>
Index Refs Address Size Wired Name (Version) &gt;Linked Against&lt;
1 77 0xffffff7f80756000 0x686c 0x686c com.apple.kpi.bsd (12.2.0)
2 6 0xffffff7f80741000 0x46c 0x46c com.apple.kpi.dsep (12.2.0)
3 101 0xffffff7f80760000 0x1b7ec 0x1b7ec com.apple.kpi.iokit (12.2.0)
4 106 0xffffff7f8074c000 0x99f8 0x99f8 com.apple.kpi.libkern (12.2.0)
5 92 0xffffff7f80742000 0x88c 0x88c com.apple.kpi.mach (12.2.0)
6 39 0xffffff7f80743000 0x500c 0x500c com.apple.kpi.private (12.2.0)
7 60 0xffffff7f80749000 0x23cc 0x23cc com.apple.kpi.unsupported (12.2.0)
8 0 0xffffff7f8146e000 0x41000 0x41000 com.apple.kec.corecrypto (1.0) &gt;7 6 5 4 3 1&lt;
9 22 0xffffff7f80d44000 0x9000 0x9000 com.apple.iokit.IOACPIFamily (1.4) &gt;7 6 4 3&lt;
10 30 0xffffff7f8088d000 0x25000 0x25000 com.apple.iokit.IOPCIFamily (2.7.2) &gt;7 6 5 4 3&lt;
11 2 0xffffff7f81dbf000 0x57000 0x57000 com.apple.driver.AppleACPIPlatform (1.6) &gt;10 9 7 6 5 4 3 1&lt;
12 1 0xffffff7f80a9e000 0xe000 0xe000 com.apple.driver.AppleKeyStore (28.21) &gt;7 6 5 4 3 1&lt;
13 6 0xffffff7f8077c000 0x25000 0x25000 com.apple.iokit.IOStorageFamily (1.8) &gt;7 6 5 4 3 1&lt;
14 0 0xffffff7f80e4d000 0x19000 0x19000 com.apple.driver.DiskImages (344) &gt;13 7 6 5 4 3 1&lt;
...
</output>
</pre>
</figure>
The kext is provided with a number of "PlugIn" kexts, namely:
<ul>
<li>AppleDiskImagesCryptoEncoding.kext</li>
<li>AppleDiskImagesKernelBacked.kext </li>
<li>AppleDiskImagesReadWriteDiskImage.kext - for UDRO/UDRW</li>
<li>AppleDiskImagesFileBackingStore.kext</li>
<li>AppleDiskImagesPartitionBackingStore.kext - Uses the Apple GUID 444D4700-0000-11AA-AA11-00306543ECAC </li>
<li>AppleDiskImagesSparseDiskImage.kext - for UDSP</li>
<li>AppleDiskImagesHTTPBackingStore.kext - Allows DMGs to reside on a remote HTTP server. Uses a "KDISocket" with HTTP/1.1 partial GETs (206) to get the chunks it needs from a DMG</li>
<li>AppleDiskImagesRAMBackingStore.kext</li>
<li>AppleDiskImagesUDIFDiskImage.kext</li>
</ul>
</section>
<section>
The attachment of a DMG starts in user mode, by an I/O Kit call to IOHDIXController, preparing a dictionary with the following keys:
<ul>
<li>hdik-unique-identifier - A UUID created by the caller (e.g. CFUUIDCreate())</li>
<li>image-path - the path to the DMG in question</li>
</ul>
Some types of disk images (sparse, uncompressed, and z-Lib compressed) are natively supported by the kernel and can be mounted directly by it. A good example is the DeveloperDiskImage.dmg found in the iOS SDK. More often than not, however, mounting resorts to user-mode helper processes. This, in fact, is default on OS X (q.v. hdiutil -nokernel vs. hdiutil -kernel). When attaching a DMG, the DiskImages private framework spawns diskimages-helper and hdiejectd. The former is started with a -uuid argument per invocation, allowing the mounting of the same DMG multiple times. If the process is stopped, filesystem operations on its contents will likewise hang (with the exception of those already cached by VFS). You can demonstrate this with a simple experiment by mounting a DMG, sending the corresponding diskimages helper a STOP signal, and performing a filesystem intensive operation, such as an ls -lR, witnessing the hang, then sending a CONT. Further inspection in GDB with a breakpoint on mach_msg will enable you to peek at the Mach messages which are passed between the process and the kernel over the I/O Kit interface. This will show a backtrace similar to:
<figure class="output">
<code>
<table>
<tr>
<td> #0 0x00007fff8cfd4c0d in mach_msg () </td><td> # Actual message passer</td></tr>
<tr>
<td> #1 0x00007fff887e3fbc in io_connect_method () </td><td> # I/O Kit internal connect</td>
</tr>
<tr>
<td> #2 0x00007fff887978ea in IOConnectCallMethod () </td><td> # I/O kit connector, generic argument</td>
</tr>
<tr>
<td> #3 0x00007fff88797ae8 in IOConnectCallStructMethod () </td><td># I/O Kit connector, with structure argument</td>
</tr>
<tr>
<td> #4 0x00007fff86e5b79f in DI_kextDriveGetRequest () </td><td> # DiskImages framework function</td>
</tr>
</table>
</code>
</figure>
Looking at the arguments to DI_kextDriveGetRequest (specifically, $rdx+ 0x20), will reveal a pointer to the data returned from the DMG file by the diskimages-helper.
<figure class="output">
<code>
(gdb) x/20x $rdx # Note this is the $rdx value at a breakpoint on DI_kextDriveGetRequest<br/>
0x103e68c30: 0x4279726f 0x00000001 0x00040208 0x00000000<br/>
0x103e68c40: 0x00000100 0x00000000 0x2dd13e80 0xffffff80<br/>
0x103e68c50: 0x03e6b000 0x00000001 0x00200000 0x00000000<br/>
<br/>
<br/>
(gdb) x/s 0x0000000103e6b000 <i>Data from a cat /Volumes/KernelDebugKit/kgmacros</i><br/>
0x103e6b000: "\n# Kernel gdb macros\n#\n# These gdb macros should be useful during kernel development in\n#<br/> determining what's going on in the kernel.\n#\n# All the convenience variables used by these macros begin wit"...<br/>
</code>
</figure>
</section>
<section>
<h1>Commands and support</h1>
Apple provides extensive support for DMGs, which is only natural given their role in everything, from aspects of OS installation to software distribution. The DMG support is provided by the DiskImages project, which contains both the user mode (hdid, hdiutil) and kernel mode (kexts) required for operation. Lamentably, Apple keeps this as one of the non-open source projects in Darwin.
<ul>
<li>hdid</li>
<li>hdiutil</li>
<li>DiskImages.framework - The private framework lending support to both the above tools, communicating with the KExts (below), as well as the user mode helper processes for mounting images (diskimages-helper and hdiejectd)</li>
<li>IOHDIXController.kext</li>
</ul>
</section>
<hr/>
<section>
Answer: Advantages of using per-block compression, rather than a single compression algorithm for entire file: <br/>
<ol>
<li> Optimize compression for type of data: For example, discard blocks of zeros rather than compressing them, or even leaving data uncompressed</li>
<li>Allow an implementation to selectively decompress chunks, rather than the whole image, which may take a lot of filesystem space and/or memory (especially in kernel-mode).</li>
</ol>
</section>
<section>
<h2>References:</h2>
<ol>
<li><a id="ref1">DMG2IMG:</a> <a href="http://vu1tur.eu.org/">http://vu1tur.eu.org</a><br/> </li>
<li><a id="ref2">DMG2ISO:</a> <a href="sourceforge.net/projects/dmg2iso/"></a>at sourceforge.net</li>
<li><a id="ref3">The book</a> <a href="newosxbook.com/">http://www.newosxbook.com</a></li>
<li><a id="ref4">APM:</a> <a href="http://www.informit.com/articles/article.aspx?p=376123&amp;seqNum=3">Discussion at informit.com</a></li>
<li><a id="ref5">TN2166: Secrets of the GPT</a> <a href="http://developer.apple.com/technotes/tn2006/tn2166.htm">developer.apple.com</a>
</ol>
</section>
</article>
</body>
</html>

BIN
FDISPEC.pdf Normal file

Binary file not shown.

1108
NRG_(file_format).html Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,233 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<title>The QCOW Image Format</title>
<body bgcolor="#ffffff">
<center><h1>The QCOW Image Format</h1></center>
<p>
The QCOW image format is one of the disk image formats supported by
the QEMU processor emulator. It is a representation of a fixed size
block device in a file. Benefits it offers over using raw dump
representation include:
</p>
<ol>
<li>Smaller file size, even on filesystems which don't support
<i>holes</i> (i.e. sparse files)</li>
<li>Snapshot support, where the image only represents changes made
to an underlying disk image</li>
<li>Optional zlib based compression</li>
<li>Optional AES encryption</li>
</ol>
<p>
The qemu-img command is the most common way of manipulating these
images e.g.
<pre>
$> qemu-img create -f qcow test.qcow 4G
Formating 'test.qcow', fmt=qcow, size=4194304 kB
$> qemu-img convert test.qcow -O raw test.img
</pre>
</p>
<h2>The Header</h2>
<p>
Each QCOW file begins with a header, in big endian format, as follows:
<pre>
typedef struct QCowHeader {
uint32_t magic;
uint32_t version;
uint64_t backing_file_offset;
uint32_t backing_file_size;
uint32_t mtime;
uint64_t size; /* in bytes */
uint8_t cluster_bits;
uint8_t l2_bits;
uint32_t crypt_method;
uint64_t l1_table_offset;
} QCowHeader;
</pre>
</p>
<ul>
<li>The first 4 bytes contain the characters 'Q', 'F', 'I' followed
by <tt>0xfb</tt>.</li>
<li>The next 4 bytes contain the format version used by the
file. Currently, there has only been a single version of the format,
version 1.</li>
<li>The <tt>backing_file_offset</tt> field gives the offset from the
beginning of the file to a string containing the path to a file;
<tt>backing_file_size</tt> gives the length of this string, which
isn't a nul-terminated. If this image is a snapshot image, then this
will be the path to the original file. More on snapshots below.</li>
<li>The mtime field can be ignored.</li>
<li>The next 8 bytes contain the size, in bytes, of the block device
represented by the image.</li>
<li>The <tt>cluster_bits</tt> and <tt>l2_bits</tt> fields, between
them, describe how to map an image offset address to a location
within the file. The <tt>cluster_bits</tt> field determines the
number of lower bits of the offset address are used as an index
within a cluster; the <tt>l2_bits</tt> field gives the number of
bits used as an index withing the L2 table. More on the format's
2-level lookup system below.</li>
<li>The <tt>crypt_method</tt> field is 0 if no encryption has been
used, and 1 if AES encryption has been used.</li>
<li>The l1_table_offset gives the offset within the file of the L1
table.</li>
</ul>
<h2>2-Level Lookups</h2>
<p>
With QCOW, the contents of the device are stored in
<i>clusters</i>. Each cluster contains a number of 512 byte sectors.
</p>
<p>In order to find the cluster for a given address within the device,
you must traverse two levels of tables. The L1 table is an array of
file offsets to L2 tables, and each L2 table is an array of file
offsets to clusters.</p>
<p>So, an address is split into three separate offsets according to
the <tt>cluster_bits</tt> and <tt>l2_bits</tt> fields. For example, if
<tt>cluster_bits</tt> is 12 and <tt>l2_bits</tt> is 9, then the
address is split up as follows:
</p>
<ul>
<li>the lower 12 is an offset within a 4Kb cluster</li>
<li>the next 9 bits is offset within a 512 entry array of 64 bit
file offsets, the L2 table</li>
<li>the remaining 43 bits is an offset within another array of 64
bit file offsets, the L1 table</li>
</ul>
<p>
Note, the size of the L1 table is a function of the size of the
represented disk image:
<pre>
l1_size = ceiling (disk_size / (cluster_size * l2_size))
</pre>
</p>
<p>In other words, in order to map a given disk address to an offset
within the image:
<ol>
<li>Obtain the L1 table address using the <tt>l1_table_offset</tt>
header field</li>
<li>Use the top (64 - <tt>l2_bits</tt> - <tt>cluster_bits</tt>) bits
of the address to index the L1 table as an array of 64 bit
entries
</li>
<li>Obtain the L2 table address using the offset in the L1
table</li>
<li>Use the next <tt>l2_bits</tt> of the address to index the L2
table as an array of 64 bit entries</li>
<li>Obtain the cluster address using the offset in the L2 table.
(Assuming the most significant bit of the cluster address is
zero. See the details on compression below.)
</li>
<li>Use the remaining cluster_bits of the address as an offset
within the cluster itself</li>
</ol>
<p>
If the offset found in either the L1 or L2 table is zero, that area of
the disk is not allocated within the image.
</p>
<h2>Snapshots</h2>
<p>
The QCOW format can represent the notion of a snapshot. That is, a
QCOW image can be used to store the changes to another disk image,
without actually affecting the contents of the original image.
</p>
<p>
The representation is very simple. The snapshot image contains the
path to the original disk image, and the snapshot image header
gives the location of the path string within the file.
</p>
<p>
When you want to read an area from the snapshot, you first check to
see if that area is allocated within the snapshot image. If not, you
read the area from the original disk image.
</p>
<h2>Compression</h2>
<p>
The QCOW format supports compression by allowing each cluster to be
independently compressed with zlib.
</p>
<p>
This is represented in the cluster offset obtained from the L2 table
as follows:
</p>
<ul>
<li>If the most significant bit of the cluster offset is 1, this is
a compressed cluster</li>
<li>The next cluster_bits of the cluster offset is the size of the
compressed cluster</li>
<li>The remaining bits of the cluster offset is the actual address
of the compressed cluster within the image</li>
</ul>
<h2>Encryption</h2>
<p>
The QCOW format also supports the encryption of clusters.
</p>
<p>
If the crypt_method header field is 1, then a 16 character password
is used as the 128 bit AES key.
</p>
<p>
Each sector within each cluster is independently encrypted using AES
Cipher Block Chaining mode, using the sector's offset (relative to the
start of the device) in little-endian format as the first 64 bits of
the 128 bit initialisation vector.
</p>
<p>
<small><a href="http://blogs.gnome.org/markmc">Mark McLoughlin</a>.
June 21, 2006.</small>
</p>
</body>
</html>

419
qcow-image-format.html Normal file
View File

@@ -0,0 +1,419 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<title>The QCOW2 Image Format</title>
<body bgcolor="#ffffff">
<center><h1>The QCOW2 Image Format</h1></center>
<p>
The QCOW image format is one of the disk image formats supported by
the QEMU processor emulator. It is a representation of a fixed size
block device in a file. Benefits it offers over using raw dump
representation include:
</p>
<ol>
<li>Smaller file size, even on filesystems which don't support
<i>holes</i> (i.e. sparse files)</li>
<li>Copy-on-write support, where the image only represents changes made
to an underlying disk image</li>
<li>Snapshot support, where the image can contain multiple snapshots
of the images history</li>
<li>Optional zlib based compression</li>
<li>Optional AES encryption</li>
</ol>
<p>
The qemu-img command is the most common way of manipulating these
images e.g.
<pre>
$> qemu-img create -f qcow2 test.qcow2 4G
Formating 'test.qcow2', fmt=qcow2, size=4194304 kB
$> qemu-img convert test.qcow2 -O raw test.img
</pre>
</p>
<h2>The Header</h2>
<p>
Each QCOW2 file begins with a header, in big endian format, as follows:
<pre>
typedef struct QCowHeader {
uint32_t magic;
uint32_t version;
uint64_t backing_file_offset;
uint32_t backing_file_size;
uint32_t cluster_bits;
uint64_t size; /* in bytes */
uint32_t crypt_method;
uint32_t l1_size;
uint64_t l1_table_offset;
uint64_t refcount_table_offset;
uint32_t refcount_table_clusters;
uint32_t nb_snapshots;
uint64_t snapshots_offset;
} QCowHeader;
</pre>
</p>
<ul>
<li>The first 4 bytes contain the characters 'Q', 'F', 'I' followed
by <tt>0xfb</tt>.</li>
<li>The next 4 bytes contain the format version used by the
file. Currently, there has been two versions of the format,
version 1 and version2. We are discussing the latter here,
and the former is discussed at the end.</li>
<li>The <tt>backing_file_offset</tt> field gives the offset from the
beginning of the file to a string containing the path to a file;
<tt>backing_file_size</tt> gives the length of this string, which
isn't a nul-terminated. If this image is a copy-on-write image, then
this will be the path to the original file. More on that below.</li>
<li>The <tt>cluster_bits</tt> fields them, describe how to map an
image offset address to a location within the file; it determines
the number of lower bits of the offset address are used as an index
within a cluster. Since L2 tables occupy a single cluster and
contain 8 byte entires, the next most significant <tt>cluster_bits</tt>,
less three bits, are used as an index into the L2 table. the L2
table. More on the format's 2-level lookup system below.</li>
<li>The next 8 bytes contain the size, in bytes, of the block device
represented by the image.</li>
<li>The <tt>crypt_method</tt> field is 0 if no encryption has been
used, and 1 if AES encryption has been used.</li>
<li>The <tt>l1_size</tt> field gives the number of 8 byte entries
available in the L1 table and <tt>l1_table_offset</tt> gives the
offset within the file of the start of the table.</li>
<li>Similarily, <tt>refcount_table_offset</tt> gives the offset to
the start of the refcount table, but <tt>refcount_table_clusters</tt>
describes the size of the refcount table in units of clusters.<li>
<li><tt>nb_snapshots</tt> gives the number of snapshots contained in
the image and <tt>snapshots_offset</tt> gives the offset of the
<tt>QCowSnapshotHeader</tt> headers, one for each snapshot.
</ul>
<p>
Typically the image file will be laid out as follows:
<ul>
<li>The header, as described above.</li>
<li>Starting at the next cluster boundary, the L1 table.</li>
<li>The refcount table, again boundary aligned.</li>
<li>One or more refcount blocks.</li>
<li>Snapshot headers, the first boundary aligned and the following
headers aligned on 8 byte boundaries.</li>
<li>L2 tables, each one occupying a single cluster.</li>
<li>Data clusters.</li>
</ul>
</p>
<h2>2-Level Lookups</h2>
<p>
With QCOW, the contents of the device are stored in
<i>clusters</i>. Each cluster contains a number of 512 byte sectors.
</p>
<p>In order to find the cluster for a given address within the device,
you must traverse two levels of tables. The L1 table is an array of
file offsets to L2 tables, and each L2 table is an array of file
offsets to clusters.</p>
<p>So, an address is split into three separate offsets according to
the <tt>cluster_bits</tt> field. For example, if <tt>cluster_bits</tt>
is 12, then the address is split up as follows:
</p>
<ul>
<li>the lower 12 is an offset within a 4Kb cluster</li>
<li>the next 9 bits is an offset within a 512 entry array of
8 byte file offsets, the L2 table. The number of bits needed
here is given by <tt>l2_bits = cluster_bits - 3</tt> since the L2
table is a single cluster containing 8 byte entries</li>
<li>the remaining 43 bits is an offset within another array of 8
byte file offsets, the L1 table</li>
</ul>
<p>
Note, the minimum size of the L1 table is a function of the size of
the represented disk image:
<pre>
l1_size = round_up(disk_size / (cluster_size * l2_size), cluster_size)
</pre>
</p>
<p>In other words, in order to map a given disk address to an offset
within the image:
<ol>
<li>Obtain the L1 table address using the <tt>l1_table_offset</tt>
header field</li>
<li>Use the top (64 - <tt>l2_bits</tt> - <tt>cluster_bits</tt>) bits
of the address to index the L1 table as an array of 64 bit
entries
</li>
<li>Obtain the L2 table address using the offset in the L1
table</li>
<li>Use the next <tt>l2_bits</tt> of the address to index the L2
table as an array of 64 bit entries</li>
<li>Obtain the cluster address using the offset in the L2 table.
</li>
<li>Use the remaining cluster_bits of the address as an offset
within the cluster itself</li>
</ol>
<p>
If the offset found in either the L1 or L2 table is zero, that area of
the disk is not allocated within the image.
</p>
<p>
Note also, that the top two bits of each of the offsets found in
the L1 and L2 tables are reserved for "copied" and "compressed"
flags. More on that below.
</p>
<h2>Reference Counting</h2>
<p>
Each cluster is reference counted, allowing clusters to be freed
if, and only if, they are no longer used by any snapshots.
<p>
<p>
The 2 byte reference count for each cluster is kept in cluster sized
blocks. A table, given by <tt>refcount_table_offset</tt> and
occupying <tt>refcount_table_clusters</tt> clusters, gives the offset
in the image of each of these refcount blocks.
</p>
<p>
In order to obtain the reference count of a given cluster, you split
the cluster offset into a refcount table offset and refcount block
offset. Since a refcount block is a single cluster of 2 byte entries,
the lower <tt>cluster_size - 1</tt> bits is used as the block offset
and the rest of the bits are used as the table offset.
</p>
<p>
One optimization is that if any cluster pointed to by an L1 or L2
table entry has a refcount exactly equal to one, the most significant
bit of the L1/L2 entry is set as a "copied" flag. This indicates that
no snapshots are using this cluster and it can be immediately written
to without having to make a copy for any snapshots referencing it.
</p>
<h2>Copy-on-Write Images</h2>
<p>
A QCOW image can be used to store the changes to another disk image,
without actually affecting the contents of the original image. The
image, known as a copy-on-write image, looks like a standalone image
to the user but most of its data is obtained from the original
image. Only the clusters which differ from the original image are
stored in the copy-on-write image file itself.
</p>
<p>
The representation is very simple. The copy-on-write image contains
the path to the original disk image, and the image header gives the
location of the path string within the file.
</p>
<p>
When you want to read an cluster from the copy-on-write image, you
first check to see if that area is allocated within the copy-on-write
image. If not, you read the area from the original disk image.
</p>
<h2>Snapshots</h2>
<p>
Snapshots are a similar notion to the copy-on-write feature, except it
is the original image that is writable, not the snapshots.
</p>
<p>
To explain further - a copy-on-write image could confusingly be called
a "snapshot", since it does indeed represent a snapshot of the
original images state. You can make multiple of these "snapshots" of
the original image by creating multiple copy-on-write images, each
referring to the same original image. What's noteworthy here, though,
is that the original image must be considered read-only and it is the
copy-on-write snapshots which are writable.
</p>
<p>
Snapshots - "real snapshots" - are represented in the original image
itself. Each snapshot is a read-only record of the image a past
instant. The original image remains writable and as modifications are
made to it, a copy of the original data is made for any snapshots
referring to it.
</p>
<p>
Each snapshot is described by a header:
<pre>
typedef struct QCowSnapshotHeader {
/* header is 8 byte aligned */
uint64_t l1_table_offset;
uint32_t l1_size;
uint16_t id_str_size;
uint16_t name_size;
uint32_t date_sec;
uint32_t date_nsec;
uint64_t vm_clock_nsec;
uint32_t vm_state_size;
uint32_t extra_data_size; /* for extension */
/* extra data follows */
/* id_str follows */
/* name follows */
} QCowSnapshotHeader;
</pre>
Details are as follows
<ul>
<li>A snapshot has both a name and ID, represented by strings (not
zero-terminated) which follow the header.</li>
<li>A snapshot also has a copy, at least, of the original L1 table
given by <tt>l1_table_offset</tt> and <tt>l1_size</tt>.</li>
<li><tt>date_sec</tt> and <tt>date_nsec</tt> give the host machine
<tt>gettimeofday()</tt> when the snapshot was created.<li>
<li><tt>vm_clock_nsec</tt> gives the current state of the VM
clock.</li>
<li><tt>vm_state_size</tt> gives the size of the virtual machine
state which was saved as part of this snapshot. The state is saved
to the location of the original L1 table, directly after the image
header.</li>
<li><tt>extra_data_size</tt> species the number of bytes of data
which follow the header, before the id and name strings. This is
provided for future expansion.</li>
</ul>
<p>
A snapshot is created by adding one of these headers, making a copy of
the L1 table and incrementing the reference counts of all L2 tables
and data clusters referenced by the L1 table. Later, if any L2 table
or data clusters of the underlying image are to be modified - i.e. if
the reference count of the cluster is greater than 1 and/or the
"copied" flag is set for that cluster - they will first be copied and
then written to. That way, all snapshots remains unmodified.
</p>
<h2>Compression</h2>
<p>
The QCOW format supports compression by allowing each cluster to be
independently compressed with zlib.
</p>
<p>
This is represented in the cluster offset obtained from the L2 table
as follows:
</p>
<ul>
<li>If the second most significant bit of the cluster offset is 1,
this is a compressed cluster</li>
<li>The next <tt>cluster_bits - 8</tt>of the cluster offset is the
size of the compressed cluster, in 512 byte sectors</li>
<li>The remaining bits of the cluster offset is the actual address
of the compressed cluster within the image</li>
</ul>
<h2>Encryption</h2>
<p>
The QCOW format also supports the encryption of clusters.
</p>
<p>
If the crypt_method header field is 1, then a 16 character password
is used as the 128 bit AES key.
</p>
<p>
Each sector within each cluster is independently encrypted using AES
Cipher Block Chaining mode, using the sector's offset (relative to the
start of the device) in little-endian format as the first 64 bits of
the 128 bit initialisation vector.
</p>
<h2>The QCOW Format</h2>
<p>
Version 2 of the QCOW format differs from the original version in
the following ways:
</p>
<ol>
<li>It supports the concepts of snapshots; version 1 only had the
concept of copy-on-write image</li>
<li>Clusters are reference counted in version 2; reference
counting was added to support snapshots</li>
<li>L2 tables always occupy a single cluster in version 2;
previously their size was given by a <tt>l2_bits</tt> header
field</li>
<li>The size of compressed clusters is now given in sectors instead
of bytes</li>
</ol>
<p>
A previous version of this document which described version 1 only
is available <a href="qcow-image-format-version-1.html">here</a>.
</p>
<p>
<small><a href="http://blogs.gnome.org/markmc">Mark McLoughlin</a>.
Sep 11, 2008.</small>
</p>
</body>
</html>

BIN
vmdk_specs.pdf Normal file

Binary file not shown.