D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Reading DMG file on Debian?

 

On 12/11/2018 17:39, Simon Waters wrote:
> On Debian stable box. Linux version 4.9.0-8-amd64
> 
> Have a DMG file I would like to examine the contents of without buying a Mac or
> anything too insane. I just want to see if one file is present, and if it is
> extract it.
> 
> The DMG may even just be a proprietary installer to download the real software
> given its small size, if it is I'll probably have to figure out how to run it,
> or file the relevant URLs it downloads and repeat.
> 
> Figure I ought to be able to use dmg2img or hfs or hfsplus, but failed
> miserably.
> 
> How do I access a DMG disk image on Linux? I have a Windows VM if it helps.
> 
> Tried variations on:
> 
>   mount -o loop -t hfs image.dmg /mnt/''somewhere''
> 
> mount: wrong fs type, bad option, bad superblock on /dev/loop4,
>         missing codepage or helper program, or other error
> 
> dmg2img gives me and img file, and "fdisk -lu" is convinced I have a "20M HFS/
> HFS+" in this image file 40 sectors in.
> 
> dmesg mostly he says:
> hfs: can't find a HFS filesystem on dev loop4
> 
> loop4 is the next free loopback device. So everything seems to understand it.
> 
> Is it just too new for my kernel, or am I missing something basic?
> 
> 
> 
> 
> dmg2img -v test.dmg
> 
> dmg2img v1.6.5 (c) vu1tur (to@xxxxxxxxxxxxx)
> 
> test.dmg --> test.img
> 
> reading property list, 9216 bytes from address 7263637 ...
> partition 0: begin=203, size=430, decoded=284
> partition 1: begin=948, size=430, decoded=284
> partition 2: begin=1695, size=430, decoded=284
> partition 3: begin=2424, size=430, decoded=284
> partition 4: begin=3137, size=1737, decoded=1164
> partition 5: begin=5157, size=430, decoded=284
> partition 6: begin=5885, size=430, decoded=284
> partition 7: begin=6630, size=430, decoded=284
> 
> decompressing:
> opening partition 0 ...         [2] 100.00%  ok
> opening partition 1 ...         [2] 100.00%  ok
> opening partition 2 ...         [2] 100.00%  ok
> opening partition 3 ...         [2] 100.00%  ok
> opening partition 4 ...        [24] 100.00%  ok
> opening partition 5 ...         [2] 100.00%  ok
> opening partition 6 ...         [2] 100.00%  ok
> opening partition 7 ...         [2] 100.00%  ok
> 
> Archive successfully decompressed as test.img
> 
> fdisk -lu test.img
> Disk test.img: 20 MiB, 20971520 bytes, 40960 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
> Disk identifier: REDACTED
> 
> Device     Start   End Sectors Size Type
> test.img1     40 40919   40880  20M Apple HFS/HFS+
> 
> 

Yeah ignore everyone who tells you that you can mount dmgs with the hfs* 
kernel modules - you can't. Forget dmg2img as well, the resulting img 
will be just as unmountable because of how Macs use filesystems.

7zip is categorically the answer here (works on Windows as well) - for 
just getting at the contents to examine them like any other compressed 
file it's perfect.

7z x myannoying.dmg

Even kpartx won't touch dmg files. Or any of the proprietary Windows 
tools that claim to be able to. The _only_ thing that can properly 
handle modern dmg files natively is a Mac as far as I can tell.

Cheers
-- 
The Mailing List for the Devon & Cornwall LUG
https://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq