How to mount dmg files on Linux


In Linux you can mount almost any formats! most people don’t know they can mount dmg files in Linux.

Dmg files are disk image format for Macintosh, file system type for dmg and cdr files in Mac is HFS+

in Linux you can mount it with this command:
# mount -o loop -t hfsplus image.dmg /path/to/directory/you/want
make sure the mount point (/path/to/directory/you/want) directory exists. you can mount it in /media/cdrom for instance if you didn’t insert any CD.

feel free to post your problems in comments

UPDATE: seems like hfsplus filesystem type is not working for everybody. there is another way of doing it. Basically DMG files are compressed IMG. So you need to decompress DMG to IMG file and then mount it. If you are using a debian-based distro, try apt-get install hfsplus first.

For that you need to download dmg2img from http://vu1tur.eu.org/tools/download.pl?dmg2img.tar.gz

Run
tar -zxvf ./dmg2img.tar.gz
cd dmg2img
make all

If everything goes okay, then you can decompress your dmg file by executing the command,
./dmg2img -i /path/to/inputfile.dmg -o /path/to/outputfile.img
and remember, you must be inside the dmg2img directory at all times in order to run the command listed above. Also, the img file needs to be in the same location as the original dmg file. And preferably, the img file should have the same name as the dmg file.
After decompressing the dmg run

sudo modprobe hfsplus

then if hfsplus is installed (if not, run sudo apt-get install hfsplus ), run

sudo mount -t hfsplus -o loop /path/to/outputfile.img /mount/point

To create the mount point, run mkdir -p /mount/location

Note: hfsplus may not be installed by default. That might be why the first method is not working for some of you.

Leave your comment if works or not.

16 thoughts on “How to mount dmg files on Linux

  1. Thank you! This was exactly the information I needed. For some reason
    using “-t auto” returned “you must specify the filetype”. I tried
    “hfs” and “ufs”, which the man page for mount(8) mentions, but it
    doesn’t list “hfsplus”. Looks like somebody (me?) needs to update the
    kernel drivers to auto recognize an hfsplus image.

    [UPDATE] I looked into adding the auto-detection to the Linux kernel.
    Strangely, it looks like Apple hasn’t given back the changes to
    recognize the magic in .dmg files to the “file” project at
    darwinsys.org. That means the the file(1) command used by all BSD and
    GNU/Linux distributions, the most fundamental command for recognizing
    the file types regardless of extension, cannot detect DMG files. How
    odd, I must be missing something. I can’t see a reason for Apple to
    keep it secret.

  2. mount: wrong fs type, bad option, bad superblock on /dev/loop0,
    missing codepage or helper program, or other error
    In some cases useful info is found in syslog – try
    dmesg | tail or so

  3. I updated this howto, if didn’t work try second method. If both doesn’t work, it’s either your dmg damaged or you do something wrong

  4. Mounts just fine,
    really has a problem with the resource/data forks in Mac OS (hfs/hfs+)
    format. data files seem o.k.

  5. I was not thinking I can mount DMG on Linux!
    Dmg2Img isn’t working for me…
    I will try mounting the DMG shortly.

  6. On Debian I had to (I was root at the time):
    apt-get install hfsplus

    then:
    mount -t hfsplus -o loop discimage.dmg /mnt/discimage

    And all was fine

  7. thanks for the instructions!

    On SLED 11 I was able to mount as a user via:

    dmg2img my.dmg
    sudo mount -t hfsplus -o loop my.img $HOME/discimage

    where I had sudo rights to use mount.

  8. Upon experimenting with opening a dmg image myself (for the purpose of checking how a py2app package was compiled, without owning an Apple machine) I found that fuse didn’t want to mount my file, resulting in the same “hfs: unable to find HFS+ superblock” dmesg error as others reported.
    After an unsuccesful with dmg2img, I tried what 7zip would make of it:
    7z x file.dmg
    To my surprise it spit out the following:
    Extracting 0.ddm
    Extracting 1.Apple_partition_map
    Extracting 2.hfs
    Extracting 3.free

    Then it was only a matter of issuing
    mount -t hfsplus -o loop 2.hfs /mnt
    on the 2.hfs file that 7zip extracted, and guess what. It worked!

    I’m in the dark about how to exactly interpret the other files, or what exactly happened when extracting it with 7zip, though. But at least I got a peek inside. :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s