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:http://ubuntuforums.org/showthread.php?p=11924128#post11924128
or the last but one posting here:http://ubuntuforums.org/archive/index.php/t-1969841.html
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
(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.
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:http://www.statman.info/conversions/hexadecimal.html
(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:
You should now have access to all the Installation files inside the image (in the /mnt/tmp directory)
sudo mkdir /mnt/tmp
sudo mount -t hfsplus /dev/loop0 /mnt/tmp/
... 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/Library/Preferences/SystemConfiguration/com.apple.Boot.plist
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:<key>Kernel Flags</key>
I changed them to:<key>Kernel Flags</key>
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 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.