Jump to content

Recommended Posts

Posted

<div class="KonaBody"><p><img src="http://osxdaily.com/wp-content/uploads/2011/12/mount-dmg-command-line.jpg" alt="Mount a DMG from the Command Line in Mac OS X" title="mount-dmg-command-line" width="620" height="166" class="aligncenter size-full wp-image-25020" /></p>

<p>A helpful command line tool called hdiutil is included in Mac OS X that allows disk image files (.dmg extension) to be mounted directly from the Terminal, without the need of using the GUI. Using hdiutil for such a task is helpful for scripting or remote connections through SSH. </p>

<h2 style="font-size:1.2em;">Mounting a Disk Image File (DMG) from the Terminal</h2>

<p>From the command line use the following syntax to mount the image:</p>

<p><code>hdiutil attach /path/to/diskimage.dmg</code></p>

<p>When the .dmg is mounted, a message will display something like this:</p>

<p><code>/dev/disk1 Apple_partition_scheme

/dev/disk1s1 Apple_partition_map

/dev/disk1s2 Apple_HFS /Volumes/Mounted Disk Image

</code></p>

<p>Take note of the last entry with the name of the just mounted disk image, you will use the first part of this line to unmount the disk (/dev/disk1s2).</p>

<h2 style="font-size:1.2em;">Unmounting a DMG from the Terminal</h2>

<p>Recalling that the device name of the mounted image, use the following syntax to unmount the dmg:</p>

<p><code>hdiutil detach /dev/disk1s2 </code></p>

<p>If you missed the device location earlier, you can retrieve information on all mounted drives and images by using:</p>

<p><code>hdiutil info</code></p>

<p>Locate the name of the mounted image and note the /dev/disk entry alongside of it.</p>

<p>The hdiutil tool <a href="http://osxdaily.com/2008/04/22/easily-mount-an-iso-in-mac-os-x/">works to mount .iso</a> and other image files as well as being able to <a href="http://osxdaily.com/2009/09/09/convert-a-dmg-to-iso-and-convert-iso-to-dmg-on-mac/">convert them</a> to other disk image formats. </p>

</div>

<p><a href="http://feedads.g.doubleclick.net/~a/WDY87VPBNDJpTYB9I9K63NPB8fI/0/da"><img src="http://feedads.g.doubleclick.net/~a/WDY87VPBNDJpTYB9I9K63NPB8fI/0/di" border="0" ismap="true"></img></a><br/>

<a href="http://feedads.g.doubleclick.net/~a/WDY87VPBNDJpTYB9I9K63NPB8fI/1/da"><img src="http://feedads.g.doubleclick.net/~a/WDY87VPBNDJpTYB9I9K63NPB8fI/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">

<a href="http://feeds.feedburner.com/~ff/osxdaily?a=gKazk11jLNk:WuaxEwxj2nk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/osxdaily?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=gKazk11jLNk:WuaxEwxj2nk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/osxdaily?i=gKazk11jLNk:WuaxEwxj2nk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=gKazk11jLNk:WuaxEwxj2nk:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/osxdaily?i=gKazk11jLNk:WuaxEwxj2nk:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=gKazk11jLNk:WuaxEwxj2nk:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/osxdaily?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=gKazk11jLNk:WuaxEwxj2nk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/osxdaily?d=qj6IDK7rITs" border="0"></img></a>

</div><img src="http://feeds.feedburner.com/~r/osxdaily/~4/gKazk11jLNk" height="1" width="1"/>

 

View the full article

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic


×
×
  • Create New...