[GUIDE] How To Build A Reliable USB Installer Using Clover 2.0 #Hackintosh

Patching the BaseSystem.dmg from the Mountain Lion Installer using the various instructions I could find around the net aren't quite the end-all of solutions. While I was able to get the USB Installer to boot and install the first stage, the resulting install would give me the old Still waiting for boot device… error, having failed to load the BaseSystem.dmg into memory. I could work around the problem by fiddling with the boot parameters, but the resulting Recovery HD partition had the same problem when booted with Clover. I wanted a reliable solution that would carry on to newer versions of Mountain Lion.



The problem was that the kernelcache file didn't contain the changes made to the BaseSystem. Most instructions recommended removing the reference to the Kernel Cache in the com.apple.Boot.plist file or adding UseKernelCache=No to the boot parameters. Finally I stumbled across a post by fau7i that gave me the final piece to the puzzle.



To build a truly reliable USB Installer stick,start by using one of the many procedures currently available here and elsewhere. I think the easiest method is to use Guillaume Géte's Lion Diskmaker to build the USB Installer, followed by the Clover 2.0 Installer to add the Bootloader. If you chose to use another method, skip any portion that tells you to remove the Kernel Cache entry in any com.apple.Boot.plist. Instead, you're going to rebuild the kernelcache file in the process of editing the BaseSystem.dmg file.



To edit the BaseSystem.dmg file, I use a modified process documented by blackosx with a few key changes inspired by the aforementioned fau7i.



After creating the USB Installer above, make the BaseSystem.dmg and kernelcache on the USB Drive visible:




Code:



cd "/Volumes/OS X Mountain Lion Install/"

sudo chflags nohidden BaseSystem.dmg

sudo chflags nohidden kernelcache



Double-click the BaseSystem.dmg to mount it. Copy the entire contents of this image to a "work folder" on the Desktop:




Code:



cd ~/Desktop

mkdir "Mac OS X Base System"

sudo ditto "/Volumes/Mac OS X Base System" "Mac OS X Base System"

diskutil unmount "Mac OS X Base System"



The last line ejected the Mac OS X Base System drive image. It isn't needed anymore.



Navigate to System/Library/Extensions/ of the work folder and add FakeSMC.kext and any other extensions you may have found necessary for your system ( Ethernet divers? ). Be sure to assign proper ownership to each added extension before proceeding. IE:




Code:



sudo chown -R 0:0 "~/Desktop/Mac OS X Base System/System/Library/Extensions/FakeSMC.kext"


Note: I tend to use shortcuts in my command lines like the 0:0 above is the equivalent of system:wheel.



This next step is the most important part of the process. We need to build a kernelcache that contains everything we need for a clean boot (Thanks fau7i!):




Code:



kextcache -volume-root "~/Desktop/Mac OS X Base System" -kernel "/Volumes/Mac OS X Base System/mach_kernel" -prelinked-kernel "~/Desktop/kernelcache" -l -n "~/Desktop/Mac OS X Base System/System/Library/Extensions"


Now that there is a viable kernelcache on the Desktop, copy it into the work folder:




Code:



sudo cp "~/Desktop/kernelcache" "~Desktop/Mac OS X Base System/System/Library/Caches/com.apple.kext.caches/Startup/"

sudo chown 0:0 "~Desktop/Mac OS X Base System/System/Library/Caches/com.apple.kext.caches/Startup/"



And also the USB Installer:




Code:



sudo cp "~/Desktop/kernelcache" "/Volumes/OS X Mountain Lion Install/"

sudo chown 0:0 "/Volumes/OS X Mountain Lion Install/"



Note that I also set the proper permissions to the files in their final locations.



Using Disk Utility, select File> New>New Image from Folder… and select the work folder on the desktop. Save it as BaseSystem and leave the Image Format at compressed and Encryption at none.



Attachment 4447



Attachment 4448



Copy the BaseSystem.dmg from the desktop to the USB Installer.




Code:



sudo cp "~/Desktop/BaseSystem.dmg" "/Volumes/OS X Mountain Lion Install/"

sudo chown 0:0 "/Volumes/OS X Mountain Lion Install/BaseSystem.dmg"



…and make the files invisible again:




Code:



cd "/Volumes/OS X Mountain Lion Install/"

sudo chflags hidden kernelcache

sudo chflags hidden BaseSystem.dmg



The USB Installer should work to run both stages of the install and create a fully bootable Recovery partition through the Clover Bootloader. Be sure to set the first boot device in BIOS setup to USB HDD until Clover is installed on the hard drive after the install is complete.



If you've already got a Recovery HD partition, you can make it Cover bootable by entering the following commands:




Code:



diskutil mount "Recovery HD"

sudo cp "~/Desktop/kernelcache" "/Volumes/Recovery HD/com.apple.recovery.boot/"

sudo cp "~/Desktop/BaseSystem.dmg" "/Volumes/Recovery HD/com.apple.recovery.boot/"



I recommend that you save the two files in case you need to rebuild a USB Installer in the future but go ahead and dispose of the work folder:




Code:



sudo rm -R "~Desktop/Mac OS X Base System"


I'm hoping that this tutorial will help others avoid all the headaches I went through to get here. Once this was solved I was able to successfully develop a reliable proceedure of installing a Fusion Drive system, consisting of a Solid State Drive merged with a Hard Disk Drive booting Windows 7, OS X and the Recovery partition. That will be the subject of my next tutorial.





source