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.

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.

11 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.

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