Use Linux to install OSX from a DMG extracted to a partition - without a Mac DVD

I used Ubuntu 10.04 (Lucid), on which all the needed apps where available in the repos… also (FYI) I used a Mac OSX 10.5 (Leopard) .dmg, but I can see no reason this shouldn’t work with a 10.6 (Snow Leopard) .dmg, 10.04 (Tiger) .dmg, or for that matter… any other OSX .dmg image.


Anyone using this tutorial to install OS X 10.7 Lion may want to take a look at the info in this posting:

or the last but one posting here:


To install OSX from a .dmg image from within Linux, and without access to a ‘working’ Mac or a ‘Mac OS X Installation DVD’… First you are going to need to install gparted, hfsplus, hfsutils, hfsprogs, and dmg2img…

sudo apt-get install gparted hfsplus hfsutils hfsprogs dmg2img

Next fire up gparted, and create 2 HFS+ PRIMARY partitions, one has to be a minimum of 8gb (or larger) and the other needs to be a minimum 30gb (or larger).

IMPORTANT - You MUST create 2 (or more) primary HFS+ partitions (see bottom).

(From here on I’m going to assume you have a .dmg file in your home directory called image.dmg)

Now you need to convert the .dmg to an .img:

dmg2img image.dmg image.img

You now have a mountable image, BUT it is a hybrid disk image… If you mount it now, all you will have access to is the first partition which does not have the installation files… They are in a hidden HFS+ partition within this image… an HFS+ partition starts with 1024 reserved bytes (for boot code), followed by the volume header… we’re going to search for that header then subtract 1024 bytes to find the beginning of the partition.
The first 4 bytes of the volume header are a signature and a version number… “H+” followed by version 4 (or “HX” followed by 5 for HFSX). So we need to look for the following hex sequence in the image - “48 2b 00 04” for HFS+ (or “48 58 00 05” for HFSX)… the storage blocks here will probably be at a block boundary and have an address that ends with “0x00”

So in a terminal:

hexdump -C image.img | grep "48 2b 00 04"

now wait… this search may take a while.

I got:
0001d600 48 2b 00 04 00 00 01 00 48 2b 4c 78 00 00 00 00 |H+…H+Lx…|

My block number is “0001d600”, and it ends with “00” so it’s my volume header block (you need to use the number you get). However the partition starts 1024 bytes before that address, so you’ll need to use an online hex converter:

(I’m going to convert the hex address ‘I’ got… YOU need to use the hex address you got)
convert 0001d600 from hex to decimal = 120320
now subtract 1024
120320 - 1024 = 119296

Now use losetup to setup the .img as a block device starting with an offset of 119296:

sudo losetup -o 119296 /dev/loop0 image.img

(be sure to use YOUR offset, not mine)
Now that the loop device is setup, all you need to do is mount it:

sudo mkdir /mnt/tmp
sudo mount -t hfsplus /dev/loop0 /mnt/tmp/

You should now have access to all the Installation files inside the image (in the /mnt/tmp directory)… Copy EVERYTHING (as root) to the 8gb HFS+ partiton you created earlier.

Now you need to find out where on the hard drive this 8gb partition is located… fire up gparted again, and count the active partitions from left to right… mine was on the First Physical Drive, 3rd active partition. (remember this)

You will need to edit (as root) the
file (on the 8gb partition), and set a kernel flag to point to this partition… i used gedit, but any text editor will do.

Look for the lines:
Kernel Flags

I changed them to:
Kernel Flags

but you will need to change rdisk0s3 to wherever YOUR 8gb partition is located.

rdisk0s3 = First Physical Hard Drive, 3rd partition (so another example would be rdisk1s2 = second HDD, 2nd partition)

Where:- rdisk0 = First HDD, rdisk1 = Second HDD etc.
and s1 = First partition, s2 = Second partition etc.

save the file.

Reboot, and after the ‘Start’ sound, hold down the ‘Option’ key (aka - Alt) and select one of the EFI partitions… if you selected the correct one… Voila… the OSX installer will start.
If you selected the wrong one, you will get a ‘No Entry’ logo displayed, just reboot, and select the other EFI partition.

Now you can either install OSX, or use the Mac OSX Disk Utility and your .dmg file, to create a bootable installation DVD, USB pendrive, USB Hard Drive etc.

Have fun :slight_smile:

If you wondered why you needed the second 30gb partition… probably because the installer NEEDS to see another HFS+ partition… deleting the Linux partition with a gparted LiveCD and creating an HFS+ one in its place would probably work (but the rdiskXsY string would need adjusting)… but if you don’t create one you WILL get a mach_kernel panic when you boot to the 8gb partition… you CAN install to this partition though, or install over the Linux partition.

I can’t condone the use of this ‘How To’ for installing OSX on a hackintosh. :wink:


So, you did this on Apple hardware running Ubuntu Linux?

I can't condone the use of this 'How To' for installing OSX on a hackintosh. ;)

Why not :wink: Using easyEFI pre-bootcd I got to the OSX installer running from the 8GB partition on an “msdos” style partioned disk, but of course the OSX installer insists on GPT style partioning and offers Disk Utility to relabel, but that would destroy the 8GB partition holding the installation files. With parted it also possible to create GPT disklabels from within Linux, but in that case the mach kernel in the 8GB partition panics. So it seems three media would work: one easyEFI bootcd, one disk with the 8GB partition, and one disk to install OSX on, but I haven’t tried that yet.

Thanks for your guide, really nice to play with all these *nix flavors on common hardware :wink:

Yes it was on an intel Mac that was running Ubuntu… the owner didn’t have an OSX Installation DVD and I don’t own a Mac so I couldn’t burn the OSX image to disk, and at the time I had no access to an external hard drive.

I’d be interested to know if your solution works, though I can see no reason why it wouldn’t… if you get round to trying it, can you let me know?

I’m glad the guide was of some use to you :slight_smile:

What an awesome and informative instructional!

After many attempts to install OSX on my HP g-72 Laptop , I found your post to be the most logical approach.
I have completed all the steps except the last one: booting.
I know this post is for running on a MAC machine, but I’m close to giving up, just thought I’d see if anyone had an idea.

How To: boot to the HFS+ partition, and install. Boot CDs such as iBoot, Empire EFI recognize the HFS Partition, but do not work.

Thanks in advance.

Glad it was of some use to you :slight_smile:

I haven’t tried to install it on non Mac hardware, I’m not really a fan of Apple or OS-X and prefer Linux, but there are a lot of sites that cover building and installing OS-X on a “hackintosh”…

Maybe someone there can help:




In particular it might be something to do with your DSDT (Differentiated System Description Table) as I think the OS-X DSDT looks for particular hardware or signatures (so won’t work with other hardware)… see here:

but you should be able to use Linux to extract your working (Linux) DSDT… decompile it… modify it… recompile it… then insert it into OS-X… but I’ve never done this so can’t really help… I could also be totally wrong.

Good luck, and let us know how you get on.

Also check this:

and Google HP G72 DSDT

Howdy. I signed up just to say thanks for your tutorial. I have had this process in the back of my mind for a little while, but lack the knowledge to do it.

I will have a crack at the process you outline in the next few days - it will be on an iMac Early 2008.

Thanks again.

You’re most welcome Marty.

Good luck :slight_smile:


Oh, nearly forgot … Welcome to the forum.