Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I've got a .dmg file, and I can't figure out how to open it. How can I open it?

share|improve this question

6 Answers 6

up vote 30 down vote accepted

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
share|improve this answer
This will not work if the dmg file has 10.6+ compressed files in it. –  HDave Oct 23 '13 at 20:14
I get this error - mount: wrong fs type, bad option, bad superblock on /dev/loop0 –  tuxdna Feb 5 '14 at 10:40
@tuxdna Do you really have a HFS image? Check the output of file file.dmg. You can also try 7z l file.dmg to list the contents. –  Lekensteyn Feb 5 '14 at 10:55
I am using dmg2img v1.6.2. I ran dmg2img on mysql-5.5.28-osx10.6-x86_64.dmg which created mysql-5.5.28-osx10.6-x86_64.img, but it doesn't mount. –  tuxdna Feb 5 '14 at 10:57
@Lekensteyn Thanks! Now it works. Check my answer below. –  tuxdna Feb 5 '14 at 11:12

To extract it, it is much more easier to use 7zip. Simply do:

7z x file.dmg
share|improve this answer
Thanks, 7z did the job, whereas dmg2img complained about a corrupted dmg image. –  rinni Jun 30 '14 at 12:42

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
share|improve this answer
You can specify the single file you want to extract: 7z x ../mysql-5.5.28-osx10.6-x86_64.dmg 4.hfs –  Lekensteyn Feb 5 '14 at 15:56

If you succeed with the instructions from Lekensteyn and binfalse more power to you. If you are getting

$ lsmod | grep hfs
hfs                    54782  0 
hfsplus                84912  0
$ sudo mount -o loop,ro -t hfsplus imagefile.img /mnt
mount: wrong fs type, bad option, bad superblock on /dev/loop0,

Right now Ubuntu only comes with dmg2img version 1.6.2 and version 1.6.4 sometimes makes a difference. Also you can extract specific partitions from a dmg and only some of them are hfs+

$ dmg2img -l file.dmg
partition 0: Protective Master Boot Record (MBR : 0)
partition 1: GPT Header (Primary GPT Header : 1)
partition 2: GPT Partition Data (Primary GPT Table : 2)
partition 3:  (Apple_Free : 3)
partition 4: disk image (Apple_HFS : 4)
partition 5:  (Apple_Free : 5)
partition 6: GPT Partition Data (Backup GPT Table : 6)
partition 7: GPT Header (Backup GPT Header : 7)
$ dmg2img -p 4 file.dmg imagefile.img
share|improve this answer

First of all install DMG2IMG. Now you can convert it to IMG:

dmg2img your.dmg new.img 

The IMG can be mounted with:

sudo modprobe hfsplus
sudo mount -t hfsplus -o loop new.img /mnt

And take a look at /mnt

share|improve this answer

When using dmg2img file.dmg imagefile.img on linux if you get ERROR: Inflation failed message, just install 7zip as

sudo aptitude install p7zip-full

and issue the following command on terminal

7z x your_file.dmg
- find the InstallMacOSX.pkg/InstallESD.dmg
- issue the command dmg2img InstallESD.dmg imagefile.img on the terminal. Now you can mount imagefile.img with

modprobe hfsplus

and then

mount -t hfsplus -o loop mountain.img /mnt
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.