Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!




MacOS - Mount/Unmou...
 
Share:
Notifications
Clear all

MacOS - Mount/Unmount DMG file from Terminal (works for ISO and IMG as well)

1 Posts
1 Users
0 Likes
1,343 Views
 Hans
(@hans)
Famed Member Admin
Joined: 10 years ago
Posts: 2549
Topic starter  

Mounting a Disk Image File (DMG) from the Terminal: 

(this works the same for ISO and IMG files as well)

hdiutil attach /path/to/your/diskimage.dmg

When the .dmg is mounted, a message will display something like this (not that hditul will try to use the dmg filename as the directory name it creates in /Volumes):

$ hdiutil attach diskimage.dmg                                                                                           9:49
Checksumming Gesamte Disk (Apple_HFS : 0)…
...........................................................................................................................................
        Gesamte Disk (Apple_HFS : 0): verified   CRC32 $75753E80
verified   CRC32 $83E2BD54
/dev/disk2          	                               	/Volumes/diskimage

Unmounting a DMG from the Terminal is just as easy:

hditul detach /Volumes/diskimage
 
or (CAUTION: where /dev/disk2 is the one hdiutil created this during mounting the DMG file)
 
hditul detach /dev/disk2

If you are not sure anymore what was mounted where, then try using this to see a list:

hdiutil info

This will output something like this (depending on your situation of course):

 

framework       : 623.100.1
driver          : 623.100.1
================================================
image-path      : /Users/hans/Downloads/diskimage.dmg
image-alias     : /Users/hans/Downloads/diskimage.dmg
shadow-path     : <none>
icon-path       : /System/Library/PrivateFrameworks/DiskImages.framework/Resources/CDiskImage.icns
image-type      : UDIF read-only compressed (zlib)
system-image    : false
blockcount      : 32768
blocksize       : 512
writeable       : false
autodiskmount   : TRUE
removable       : TRUE
image-encrypted : false
mounting user   : hans
mounting mode   : <unknown>
process ID      : 52538
framework name  : DiskImages
/dev/disk2		/Volumes/diskimage

   
ReplyQuote

Like what you see and you'd like to help out? 

The best way to help is of course by assisting others with their questions here in the forum, but you can also help us out in other ways:

- Do your shopping at Amazon, it will not cost you anything extra but may generate a small commission for us,
- send a cup of coffee through PayPal ($5, $10, $20, or custom amount),
- become a Patreon,
- donate BitCoin (BTC), or BitCoinCash (BCH).

Share: