Dmg file contains a volume with identifier Apple_HFS, which is compressed with various methods (zlib, bz2, etc.), how can I extract a raw, uncompressed HFS volume from DMG file?

Right now, it cannot be done with Catacombae - HFSExplorer, due to unknown block type, with the 0x80000007 identifier, which is probably LZFSE compression method, 7z also won't do a good job.

Command line tool would be nice. I can't mount it and extract files because I want exactly, let say Apple_HFS.hfs file.


Solution, mount dmg file on mac, dump it to img file and extract HFS volume

open [path/to/dmg]
dd if="/dev/disk[number]" of="/extract/path/file.img"

and then on linux I looked up sector size and where HFS volume starts, by:

fdisk -l file.img

Example output:

Disk test.img: 1.3 GiB, 1391718400 bytes, 2718200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Device      Start     End Sectors   Size Type
test.img1      40  409639  409600   200M EFI System
test.img2  409640 2456015 2046376 999.2M Apple HFS/HFS+

in this example, sector size is 512 bytes and hfs volume starts at 409640th sector and is 2046376 sectors long.

Now extract volume

dd if="path/to/file.img" bs=sector_size skip=sectors count=sectors >> output.hfs

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .