Wednesday, September 7, 2011

Mounting DMG images, the hard way

Opening a DMG in the finder is a fast way to get it mounted. The manual steps are broken down as follows:

Attach the disk image (if you omit the 'nomount' flag it will do the mounting automatically, I'm stopping that for demonstration purposes)
root# hdiutil attach -nomount testing.dmg
/dev/disk1           Apple_partition_scheme          
/dev/disk1s1         Apple_partition_map             
/dev/disk1s2         Apple_Driver_ATAPI              
/dev/disk1s3         Apple_HFS                
The disk now exists:
dhcp-172-26-92-208:images root# diskutil list
[...snip...]
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     Apple_partition_scheme                        *4.2 GB     disk1
   1:        Apple_partition_map                         30.7 KB    disk1s1
   2:         Apple_Driver_ATAPI                         2.0 KB     disk1s2
   3:                  Apple_HFS Mac OS X                4.2 GB     disk1s3
And you can mount all partitions like this:
diskutil mountDisk /dev/disk1
or just one with:
diskutil mount /dev/disk1s3
Since we didn't specify targets, they will appear under /Volumes.

No comments: