Jump to content

Scriptable Utility to Create a Mountain Lion USB Installer


i am oz
 Share

3 posts in this topic

Recommended Posts

Mountain Lion USB Installer Creator

 

Creates a USB installer for OS X Mountain Lion.

 

Must be run as root.

 

User is required to supply the path to InstallESD.dmg or have

Install OS X Mountain Lion.app sitting in /Applications.

 

Default kernel is vanilla, use '-c amd' to install AnV RC4 amd_kernel as

mach_kernel.

 

You can modify the kit or use '-k <path>' to customize the installer:

- Chameleon can be updated by replacing the files in Chameleon/i386.

 

- /Extra is copied over from Chameleon/Extra, so files added or changed there

will be copied to the new system for you.

 

- Extensions get copied to /System/Library/Extensions from the Extensions

folder.

 

- Launch daemons are installed from LaunchDaemons to /Library/LaunchDaemons.

 

- Custom actions can be executed at the end of the installation by modifying the

bash script postinstall.sh. The script is sourced by bless, so the

environment includes the log function and various useful variables. See the

script for more information.

 

- If you use the option to install an AMD kernel, you can replace amd_kernel

in the kit and it will get installed as mach_kernel on the installer and the

installed system. That way you can use some other legacy kernel instead

of the stock default.

 

- usr gets copied to /usr on the installer, but not the installed system.

This can still be useful if you want to use a utility in Terminal that

isn't available on the installer by default.

 

- The whole kit gets copied to /opt/kit on the installer. Again, probably only

useful to advanced users.

 

The '-y' option is great when you don't want to sit around watching for any

prompts that might pop up ;) (also for scripts)

 

The '-v' option gives lots of nice progress reporting while copying files,

for those that get paranoid when a utility sits with no output for a while.

 

Give your USB volume a fancy custom label with the '-l' option.

 

Ozlog is some ridiculous display of jumping through hoops to monitor the

bless hijack on the installer, and probably doesn't deserve to be included

with this utility. It may be useful to someone, but consider these options

seriously advanced. It should be harmless, but is generally useless. If you

want to use it, run `netcat -l 1234' on the host specified by '-a' to see

the log. It is only used when bless is called, at the very end of the

install process. Check out the log function at the top of usr/sbin/bless for

an example of how to use the installer side.

 

So, why would you want to monitor bless? Bless is what screws up some

other installer utilities and causes them to say "Installation Failed" at the

end, even though the system is still installed successfully. If you look in

the kit at usr/sbin/, you'll see that there is a bash script there called bless.

This script is the bless hijack, and it tricks the installer into succeeding!

It also installs Chameleon, /Extra, ensures the amd_kernel replaces

mach_kernel, copies over kexts, etc. This script replaces the stock bless

and therefore gets called at the end of the installation. If you had something

special you wanted your installer to do, you could put it in kit/ and modify

bless to call your script or whatever else you can imagine would be neat.

 

Bonus tip: You can use the following command to create a blank dmg.

hdiutil create -size 5g -format UDWR -attach installer.dmg

The output will list a device (like /dev/disk1) that you can use as the

argument to this utility. Then you'll have a .dmg you can keep, and restore

to a USB drive whenever you need it, instead of having to rebuild it with

this program.

 

hack:~ oz$ sudo ./mlusbcreator
Usage: mlusbcreator [-h]
mlusbcreator [-vy] [-k KIT] [-e ESD] [-l LABEL] [-c amd|intel] [-o -a ADDRESS [-p PORT]] target

Options:
-h, --help show this help message and exit
-v, --verbose display more info when copying files
-y, --yes automatically answer yes to all questions (useful for scripting)
-k KIT, --kit=KIT custom path to the hack kit (default: ./kit)
-e ESD, --esd=ESD custom path to InstallESD.dmg (default: /Applications/Install OS X Mountain Lion.app/SharedSupport/InstallESD.dmg)
-l LABEL, --label=LABEL custom label for the USB volume (default: Mountain Lion USB Installer)
-o, --ozlogd enable remote logging of bless hijack, requires -a and -p
-a ADDRESS, --address=ADDRESS ip address to send log messages to
-p PORT, --port=PORT custom port to sent log messages to (default: 1234)
-c CPU, --cpu=CPU explicitly set cpu type of target system (default: intel)

Brought to you by oz and SS01

 

Example usage:

hack:~ oz$ sudo ./mlusbcreator -y --verbose --esd=InstallESD.dmg --cpu=amd /dev/disk1

 

Get the latest version at http://oz.freqlabs.com/osx86/mlusb.zip

Edited by i am oz
  • Like 2
Link to comment
Share on other sites

Congratulations, man!

 

Great tool! I tested when you sent me the link on the chat and - sorry not to tell you before, so many thinks occupying my worries these days - i can confirm it works as described, and now i have a fancy USB AMD ML installer. :D

 

Best regards!

  • Like 1
Link to comment
Share on other sites

I'd like to quickly mention a few more things about this software:

 

The mlusbcreater Python script, as well as the bless and ozlogd bash scripts, are open source under the Apache License, Version 2. See http://www.apache.or...ICENSE-2.0.html for the full license.

 

Secondly, I want to highlight some of the possible ways to use this. You can easily build a kit for a specific hardware configuration by simply copying the kexts to kit/Extensions/, then run the script, or zip it back up and share with others. Or you could go even further and use it as the backend to your own application.

 

I wish I could edit the topic title, I would make it less rhetorcal and a bit more descriptive :) Figured out how to do that.

  • Like 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...