How to open and eject a Disk Copy (.dmg file) from the command line (CLI) on Mac OS X 10.3.5+.
Open a Disk Copy Disk Image File (.dmg)
The following will mount the target.dmg in /Volumes/.
hdid target.dmg
To open an encrypted .dmg from the command line, use
hdid -stdinpass target.dmg
and enter the password when prompted.
Eject a Mounted Disk Copy Disk Image (.dmg)
First, use "df" to determine what device the image is associated with, like so
$ df /Volumes/target Filesystem 512-blocks Used Avail Capacity Mounted on /dev/disk1s2 81840 17864 63976 22% /Volumes/target
Then hdiutil detach to unmount the device, like so
hdiutil detach /dev/disk1s2
where dev/disk1s2 is the path of the device you want to unmount.
See also: Mac OS X Tips [http://xahlee.org/UnixResource_dir/macosx.html]
