Nov 9, 2008

dmg files

HowTo open .dmg file (Mac Disk Images) with Linux
Ever downloaded some nice Wallpaper from a Macpage?
Or icons?
Or anything else?

Well if, you probably know about unstuff, that - sometimes (ok, most times) - will ecompress the .sit.hqx, .sit.bin or .sit.whatever stuffit file. But then, all you gets a f****** stupid useless .dmg file you cannot handle. No Wallpaper, No icons - NOTHING!!! Well, don't worry. You actually can open it with Linux (as we know, there's nothing this OS can't do :)
.dmg are Disk Images of the Apple FS HFS - nothing more, nothing less.
And you can mount this as any Disk image =)

First, be sure you really have a true hfs Disk Image:
:~$ file myImage.dmg
Should result like this:
Real Poof.dmg: Macintosh HFS data (mounted) created: Sun Jul 6 17:43:33 2003,
last modified: Sat Mar 6 09:33:12 2004, block size: 512, number of blocks: 4090,
volume name: RealPoof

With Linux, Disk Images are mounted as loop devices, so the appropriate command would look like this:
:~$ mount -t hfs -o loop myImage.dmg /macdisk
VoilĂ  :) The Image is mounted to /macdisk. (of course, there should be a directory like this ;)

Unfortunately, you must be root to do so - and the Image is only available to the root user.
Therefore we should enhance that a bit.
First, you need to make a new entry to /etc/fstab. (beginners: you must be root for this ;)
Add a line like this:
/tmp/hfsimage /macdisk hfs defaults,noauto,user,loop 0 0
Now any user can mount such an image.
However, the mounted file is /tmp/hfsimage ...
So we should create this as a symlink to our actual image:
:~$ ln -sf myImage.dmg /tmp/hfsimage
(the -f switch will just overwrite any existing link - or file, so please do not copy or hardlink files to /tmp/hfsimage)

No comments:

Post a Comment