How can I open a .dmg file?

To extract it, it is much easier to use 7zip:

7z x file.dmg

Install dmg2img Install dmg2img.

Next, read the package information page and the manual page to see if it is useful to you.

The application seems to convert .dmg to a file that can be mounted using the mount command:

dmg2img file.dmg imagefile.img

From your Wikipedia article, the next command seems to be available to do that:

sudo mount -o loop -t hfsplus imagefile.img /mnt

In this way, the file imagefile.img is a result from dmg2iso and the contents will be available at /mnt. If the hfsplus type is not detected, you might need to load the kernel module for it:

sudo modprobe hfsplus

When done, you can unmount it by running:

sudo umount /mnt

This works for me:

  • Extract using 7z x
  • Locate the hfs partition file
  • Mount it to a directory

Extract using 7z x

root # aptitude install p7zip-full
root # 7z x ../mysql-5.5.28-osx10.6-x86_64.dmg 

7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=en_IN,Utf16=on,HugeFiles=on,4 CPUs)

Processing archive: ../mysql-5.5.28-osx10.6-x86_64.dmg

Extracting  0.MBR
Extracting  1.Primary GPT Header
Extracting  2.Primary GPT Table
Extracting  3.free
Extracting  4.hfs
Extracting  5.free
Extracting  6.Backup GPT Table
Extracting  7.Backup GPT Header

Everything is Ok

Files: 8
Size:       125475840
Compressed: 117543935
root # ls
0.MBR  1.Primary GPT Header  2.Primary GPT Table  3.free  4.hfs  5.free  6.Backup GPT Table  7.Backup GPT Header

Locate the hfs partition ( here it is 4.hfs file ):

root # ls -l
total 122548
-rw-r--r-- 1 root root       512 Feb  5 16:06 0.MBR
-rw-r--r-- 1 root root       512 Feb  5 16:06 1.Primary GPT Header
-rw-r--r-- 1 root root     16384 Feb  5 16:06 2.Primary GPT Table
-rw-r--r-- 1 root root      3072 Feb  5 16:06 3.free
-rw-r--r-- 1 root root 125435904 Feb  5 16:06 4.hfs
-rw-r--r-- 1 root root      2560 Feb  5 16:06 5.free
-rw-r--r-- 1 root root     16384 Feb  5 16:06 6.Backup GPT Table
-rw-r--r-- 1 root root       512 Feb  5 16:06 7.Backup GPT Header

Mount it to folder:

root # mkdir t
root # mount -oloop 4.hfs t
root # cd t/
root # ls
mysql-5.5.28-osx10.6-x86_64.pkg  MySQL.prefPane  MySQLStartupItem.pkg  ReadMe.txt