Mount Apple Disk Images (DMG) in Linux

Apple’s disk images represent volumes which can be divided into several partitions, typically formatted with HFS or HFS+.

These volumes can’t be read just by Apple computers but also from Windows and Linux PCs.

Arch Linux comes with native support of the Hierarchical File System (HFS) but other distributions with older kernels such as Debian don’t.

Best you check with find /lib/modules -name "*hfs*" if the required modules get listed. If there are none listed use your package manager to find the appropriate packages.

  • Ubuntu/Debian: aptitude search hfs
  • Open Suse: zypper search hfs
  • Fedora: yum search hfs

With aptitude|zypper|yum install ... you can install the appropriate packages.

Worth to mention is that in Linux only uncompressed DMGs can be directly mounted. The file command will tell you the actual type of a file.

$ file Adium.dmg 
Adium.dmg: bzip2 compressed data, block size = 100k

The above output shows us that the disk image is compressed with the bzip2 algorithm and thus we can’t mount the image directly. For an uncompressed image the output would look like

$ file uncompressed.dmg
uncompressed.dmg: Macintosh HFS Extended version 4 data last mounted by [...]
block size: 4096, number of blocks: 6400, free blocks: 218

Mount an uncompressed DMG

This uncompressed image can be mounted with

sudo mount -t hfsplus -o loop Adium.dmg /mnt

If you get a wrong filesystem type error message such as below, inspect the kernel modules loaded.

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

You need to load the loop and one of both, hfs or hfsplus, loaded depending on your DMG filesystem format.

sudo modprobe loop
sudo modprobe hfs
sudo modprobe hfsplus

Mount a compressed DMG

To mount compressed disk images some more effort is required because they first need to be converted to a raw image. That’s where the dmg2img tool comes into action.

$ dmg2img Adium_1.5.4.dmg

dmg2img v1.6.4 (c) vu1tur (

Adium_1.5.4.dmg --> Adium_1.5.4.img

opening partition 0 ...             100.00%  ok
opening partition 1 ...             100.00%  ok
opening partition 2 ...             100.00%  ok

Archive successfully decompressed as Adium_1.5.4.img

Now we can mount and see what’s inside the image.

$ sudo mount -t hfsplus -o loop Adium_1.5.4.img /mnt
ls -l /mnt
total 200
drwxr-xr-x 1 501 utmp      3 Nov  7 10:47
-rw-r--r-- 1 501 utmp      0 Nov  7 10:48 Applications
-rw-r--r-- 1 501 utmp 176566 Nov  7 10:48 Changes.txt
-rw-r--r-- 1 501 utmp  21015 Nov  7 10:48 License.txt

Be warned that some images may have big partitions as in xampp.dmg, the distributed DMG of the XAMPP project of the Apache Friends. dmg2img made a 33 GB raw image out of the original 86 MB big DMG. In the case where DMGs are used to distribute a software package which should be dragged to the /Applications folder, their creators should consider users with limited storage regardless the write capabilities of DMGs.

It would be nice to see how big the raw image will finally become before we actually convert the DMG into a raw image. If somebody knows a tool to do so, raise your voice.


  1. Thanks, I found this article very useful.

  2. Carlos E:

    Excelent, all is very clear y useful

  3. Helpful, thanks!

    One further question: What about encrypted DMG files?

  4. nba shop coupons codes (Jacqueline) nba shop discount

  5. db

    Do you know how to mount a sparsebundle?

    This is what happens when I try

    % sudo mount -t hfsplus -o loop mm.sparsebundle/token /mnt/
    mount: mounting 0[ on /mnt/ failed: Invalid argument

    % sudo mount -t hfsplus -o loop mm.sparsebundle/ /mnt/
    mount: mounting mm (rsync).sparsebundle/ on /mnt/ failed: Block device required

  6. If images are compressed with bzip2, is it not possible to simply decompress them using the bzip2 command on linux and then mount them? And where images contain more than one partition, the kpartx command should be able to map the partition offsets within the file.

  7. Tekate

    Thank you for this help!

  8. Woe ! Its awesome, excellent and very useful. Thanks for this.

  9. get a life

  10. Bruce Korb

    $ sudo bash -c ‘modprobe loop;modprobe hfs;modprobe hfsplus’
    $ sudo mount -t hfsplus -o loop Hackintosh-HSierra-Install.img $PWD/macOSUpd10
    mount: /u/bkorb/RPM/hackintosh/macOSUpd10: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.

    I’ve copied that image to a thumb drive and it starts working, then fails. I need to replace some of the files on it. But my Mac is dead and I need to boot off the thumb drive to revive it. :(

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>