Jump to content

How to Install OS X 10.x (Snow Leopard to El Capitan) in VMware Workstation 10/11, Workstation Pro/Player 12, Player 6/7, ESXi 5/6

410 posts in this topic

Recommended Posts

I originally wrote this "How To" in the following topic "Workstation 8/9, Player 4/5 and Fusion 4/5 Mac OS X Unlocker" started by Donk, see link below, since there are now some 500+ replies in the topic, I thought it was time to extract the post and start a new topic.




Although a lot of alternative methods are available, the following "How To" based on the work by Donk, Zenith432 and others on "InsanelyMac" is a proven method for installing a "Vanilla / Retail" version of OS X 10.6 (Snow Leopard), 10.7 (Lion), 10.8 (Mountain Lion), 10.9 (Mavericks), 10.10 (Yosemite) and 10.11 (El Capitan) under VMware Workstation 10/11, Player 6/7, Workstation Pro/Player 12 and ESXi 5/6, using physical media (Snow Leopard) or an email with a content code for the Mac App Store (Lion and Mountain Lion) purchased from the Apple Store or media created from the App Store download. If you have access to an existing OS X machine physical or virtual you can download OS X 10.9 (Mavericks), 10.10 (Yosemite) or 10.11 (El Capitan) for free. It is important for the method detailed below to work, you must be running a relatively recent Intel processor with VT-x (Hardware Virtualisation) support which has been enabled in BIOS.


Install the "Unlocker" following the included readme.txt, version 1.3.x for Workstation 10, Player 6 or ESXi 5 and "Unlocker" version 2.0.x for Workstation 11, Player 7, Workstation Pro/Player 12 and ESXi 6 created by Donk based on work by Donk, Zenith432 and Sam B, see the links below, to enable support for OS X. If you have access to an OS X machine, Redeem your purchase and download OS X from the Mac App Store under Purchases or use Updates to get OS X 10.9 (Mavericks), 10.10 (Yosemite) or 10.11 (El Capitan) once downloaded on your OS X machine extract the InstallESD.dmg from your App Store download of "Install OS X Lion" or "Install OS X Mountain Lion" in the Applications folder, right click the icon and select "Show Package Contents" open folder "SharedSupport" and copy the InstallESD.dmg to your desktop.


Link to the "Unlocker" download to support Workstation 10.x, Player 6.x, Fusion 6.x and ESXi 5.x:




Link to the "Unlocker" download to support Workstation 11.x, Workstation Pro 12.x, Player 7.x, Workstation Player 12.x, Fusion 7.x, Fusion 8.x and ESXi 6.x:




Please note this media creation method will NOT work for OS X 10.9 (Mavericks), OS X 10.10 (Yosemite) or OS X 10.11 (El Capitan) an apple script is required to create a bootable DMG file from the "Install OS X Mavericks" or "Install OS X Yosemite" app downloaded from the Mac App Store, see the second post in this thread for details, link below:




If you do not have access to an OS X machine, then purchase the OS X Snow Leopard DVD from the Apple Store ($19.99 US or £14.00 UK), you can use the DVD directly but it is easier to covert the DVD to an ISO.


In order for you to be able to use the .dmg created for Lion or Mountain Lion as install media in Workstation 10/11 or Player 6/7 (Workstation Pro 12, Workstation Player 12, Fusion 6, 7 and 8, ESXi 5.1, 5.1 U1, 5.5, 5.5 U1, 5.5 U2, 5.5 U3, ESXi 6.0 and ESXi 6.0 U1x support .dmg files directly) the .dmg will have to be converted to an .iso, this can be done at the command line in OS X see below or in Windows using a third party product like ImgBurn ( http://www.imgburn.com/ ) or dmg2img ( http://vu1tur.eu.org/tools/ ) .


In an OS X terminal session run the following:


cd Desktop

hdiutil convert ./InstallESD.dmg -format UDTO -o InstallESD

mv InstallESD.cdr InstallESD.iso


The conversion process will take some time, so apply the cup of coffee rule. The conversion process actually creates a .cdr file which we rename with the mv command to a .iso which can be mounted as installable media in Workstation 10/11 and Player 6/7.


If the "Unlocker" has been installed correctly you should now be able to create a new Apple Mac OS X Guest operating system in Workstation 10/11, Workstation Pro 12, Player 6/7, Workstation Player 12 and ESXi 5/6 and select the InstallESD.iso you have created as the "Installer disc image file (iso):" and select Apple Mac OS X as the "Guest operating system" and Mac OS X Server 10.6 64-bit, Mac OS X 10.7 64-bit, Mac OS X 10.8 or Mac OS X 10.9 as the "Version". Mac OS X 10.9 can be installed from the .dmg created via the script detailed in the second post of this topic as can Mac OS X 10.10 which is only available as an option in Workstation 11, Workstation Pro 12, Player 7, Workstation Player 12 and ESXi 6, although Mac OS X 10.10 or 10.11 can be installed in Workstation 10, Player 6 or ESXi 5 using Mac OS X 10.9 as the "Version". Please note Mac OS X 10.11 is only available as an option in Workstation Pro 12, Workstation Player 12 and ESXi 6.


Next choose a name and location for the virtual machine, then specify the "Maximum disk size (GB):" (I always select a minimum of 64 GB) and whether to "Store virtual disk as a single file" or "Split virtual disk into multiple files", (I select single file for ease of portability, but in theory selecting multiple files should offer better performance), however the default settings work fine.


You now have the option to either Finish and create the Virtual Machine or "Customize Hardware...", I recommend adding a second core under the "Processors" section (although you may get the "Your Mac OS guest might run unreliably with more than one virtual core." warning message) and change the "Network Adapter" to "Bridged" (in theory these are optional, the default settings should will work fine, but experience would suggest using the recommended settings) select Close and Finish.


It has been noted, thanks to cb4, that sometimes you get no keyboard input in the virtual machine, setting the "Enhanced virtual keyboard" from "Off" to "Use if available (recommended)" resolves the issue, and does not appear to have any issues when set on for a working OS X Virtual Machine.


To disable the VMware multiple vCPU message add the following line to the VMX configuration for the guest whilst it is shutdown.


isolation.tools.bug328986.disable = "TRUE"


Please note this will only suppress the message, and the guest may be unstable with more than 1 vCPU, however since it is a very long time since real Mac's were not at least dual core, I always add at least two vCPU's, and have not experienced any instability. Thanks to Donk for the fix, for additional information head over to the website "Shine The Braille Toad".


If you create the virtual machine using version 11 or later hardware, the default for Workstation 11, the virtual machine will not start and either hang or create a CPU core dump error message. Donk has confirmed two options to work around the issue:


1. Change the virtual machine to version 10 hardware.

2. Edit the configuration file (.vmx) and add the following line: smc.version = "0"


Power on the virtual machine and the OS X installation should proceed to the Welcome screen, select your main language, and in the OS X Utilities screen select Disk Utility. In the left panel you should now see 68.72 GB VMware Virtual SATA Hard Drive Media, or similar depending on the hard drive size you set when creating the virtual machine, select the drive, and select the Partition tab. Next change the Partition Layout: from "Current" to "1 Partition", you can select more than one partition but I generally keep it simple, give the Partition a meaningful name, i.e. OS X, and click on the Apply button (the default format "Mac OS Extended (Journaled)" should be selected, and under the "Options..." button "GUID Partition Table" should be selected), you will next get an "Are you sure" warning, click on the Partition button to complete the creation of OS X formatted partition, you should see it appear below the VMware Virtual SATA Hard Drive Media.


The DIsk Utility presentation has changed in El Capitan, having selected the VMware Virtual SATA Hard Drive Media as detailed above select the Erase button, the Partition button will be grayed out, and give the drive a meaningful Name: i.e. OS X and select "OS X Extended (Journaled)" as the Format: finally select "GUID Partition Map" as the Scheme and press the blue Erase button to create the drive ready for use by OS X.


Now exit Disk Utility and select Reinstall or Install OS X, click Continue at the Install OS X screen and agree to the Apple EULA, at the Select the disk where you want to install OS X, you should have a nice yellow OS X disk in the middle of the screen, select the disk and click on Install, the installation should then proceed with a blue progress bar and "About 9 minutes remaining", following a re-boot OS X will continue "Installing OS X on the disk "OS X ..." again with a blue progress bar and "Time remaining: About 19 minutes", if the screen goes white with only a black mouse pointer, just click to bring back the install OS X screen.


Following a further re-boot you should finally be at the Welcome screen with a map of the world and the option to select your language, followed by "Select Your Keyboard" to get the best support for a PC keyboard select the Show All and choose the relevant "Your Language - PC" version, i.e. British - PC.

The next couple of screens may or may not appear depending on your network configuration, "How Do You Connect?", "Your Internet Connection" probably best to leave "TCP/IP Connection Type" Using DHCP initially.

The next screen to appear is the "Transfer Information to This Mac", "Sign in with Your Apple ID" if you choose Don't sign in, you will get a splash screen with the option to "Skip", "Terms and Conditions", "Create Your Computer Account", "Select You Time Zone", "Diagnostics & Usage" followed by a "Setting up your Mac" and a thank you from Apple you should then be at the OS X desktop.


This will create a vanilla install of OS X which can and should be patched via "Software Update..." as a matter of priority.


It appears that like ESXi 5.5 and ESXi 6, Workstation Pro/Player 12 using Unlocker 2.0.7 or later, Install VMware Tools... under the VM tab now appears to work, if not use the method as for previous versions of Workstation and Player detailed below:


To install "VMware Tools" go to the Virtual Machine Settings for the OS X VM and select CD/DVD (IDE) and under "Connection" click on "Use ISO image file:". It is quite likely your InstallESD.iso will still be selected, so just "Browse..." to the location of the darwin.iso and select "Open". The darwin.iso is not present in a standard install of either Workstation 10/11, Workstation Pro 12, Player 6/7 or Workstation Player 12, it is added as part of the "Unlocker" install and is located in the VMware Workstation folder under "Program Files (x86)\VMware" or "Program Files\VMware" for a 32-bit host in a default install, make sure the "Device status" has "Connected" ticked generally "Connect at power on" is ticked by default.


You may get an error when switching mounted .iso's in the Virtual Machine Settings "The guest operating system has locked the CD-ROM door..." it is OK to answer "Yes" to the question "Disconnect anyway and override the lock?".


In your OS X desktop a VMware Tools icon should appear in the upper right corner, double click and select "Install VMware Tools", it is recommended to install VMware Tools as it offers an enhanced user experience when working with the Virtual Machine. Please note VMware Tools cannot be installed from the menu in Workstation 10/11 or Player 6/7 to an OS X Virtual Machine (unlike Fusion, ESXi 5.x snd ESXi 6.x and now Workstation Pro 12 and Workstation Player 12 which support VMware Tools installation from the menu).


The latest VMware Tools from Fusion 7/8 now provide the best graphics support for OS X virtual machines, and Zenith432 has stopped development of the VMsvga2 graphics drivers. The latest darwin.iso is available to download at the VMware CDS Repository, see link below:






Once you are up and running with your virtual OS X machine you need to do a couple of housekeeping tasks to ensure your virtual machine does not freeze. Firstly go to "System Preferences" and select "Energy Saver" and set "Computer sleep:" and "Display sleep:" to Never and also un-tick "Put hard disks to sleep when possible", "Wake for Ethernet network access" and "Allow power button to put the computer to sleep". In "Desktop & Screen Saver" set "Screen Saver" to "Start after:" Never.


One final note, occasionally you can come across an unsupported CPU error, this should be rare if you have recently downloaded your OS X media from the App Store as the App Store version is updated when a new combo patch is released. Alternatively if your CPU is one of the very latest Intel processors not yet supported by OS X, Apple check CPUID's when installing OS X, and will not install on an unsupported processor platform.


(A prime example was when Intel introduced the Core i3, i5 and i7 and Xeon 5600 series processors, Snow Leopard 10.6.4 was the lowest version of OS X to support the new processors, unfortunately the highest available "vanilla" media was and still is 10.6.3, without the CPUID mask it was impossible to install OS X Snow Leopard. As stated earlier in this post, Apple starting with OS X 10.7 Lion deliver the latest slipstreamed media via the App Store.)


In either case add the following line to your OS X virtual machine configuration file (.vmx):


cpuid.1.eax = "0000:0000:0000:0001:0000:0110:1010:0101" or cpuid.1.eax = "----:----:----:0010:----:----:1010:0111"


The first was based on work by myself and Donk, the second a recommendation by jmattson of VMware, see links below:





Edited by MSoK
  • Like 16
Link to comment
Share on other sites

As with OS X Mountain Lion (10.8) several methods are available to install Mavericks (OS X 10.9), Yosemite (OS X 10.10) or the recently released El Capitan (OS X 10.11) as a free upgrade, thanks Apple!


Mavericks (OS X 10.9), Yosemite (OS X 10.10) or El Capitan (OS X 10.11) can be installed as a FREE UPGRADE on an existing OS X Snow Leopard (10.6.8) or later virtual machine, but make sure your virtual machine to be upgraded meets the minimum specification for Mavericks, Yosemite or El Capitan (2 Processors and 2 GB RAM), by default OS X Snow Leopard installs with 1 Processor and 1 GB RAM, so edit the virtual machine settings before attempting an in-place upgrade. I would also advise making sure your to be upgraded OS X virtual machine is fully patched, and take a snapshot before you start.


To install Mavericks (OS X 10.9), Yosemite (OS X 10.10) or El Capitan (OS X 10.11) as a fresh install is more complicated as extracting the DMG file as detailed in the first post of this topic does NOT create a bootable image.


In order to create a bootable DMG that works in both Workstation 10/11/12, Player 6/7/8 and ESXi 5.5/6.0 requires an Apple script to create the bootable DMG from the "Install OS X Mavericks", "Install OS X Yosemite" or "Install OS X El Capitan" app downloaded from the Mac App Store.


Download the "Install OS X Mavericks", "Install OS X Yosemite" or "Install OS X El Capitan" app from the Mac App Store, it will appear as a free upgrade under Updates, the default location is /Applications/Install OS X Mavericks.app, /Applications/Install OS X Yosemite.app, or /Applications/Install OS X El Capitan.app, if you have not downloaded to the default location or copied the app from another machine then make a note of the location as the Create Mavericks Installer (CMI.tool) or Create Yosemite Installer (CYI.tool) script will require the location as an appended parameter (inputApp="$1") when run. Currently the CECI.tool only supports downloading El Capitan to the default location.


Download the attached "CMI.tool.txt", "CYI.tool.txt" or "CECI.tool.txt" script file to your OS X 10.x desktop and rename (in a terminal session) the file to remove the .txt extension:


mv CMI.tool.txt CMI.tool or mv CYI.tool.txt CYI.tool or mv CECI.tool.txt CECI.tool


IMPORTANT do not modify the script unless you are using a script editor as using a standard text editor adds end of line markers, which causes the script to hang, run with errors or do nothing.


Next we need to make the script executable, again in a terminal session run the following command:


chmod +x CMI.tool or chmod +x CYI.tool or chmod +x CECI.tool


Run the script file (in a terminal session) as shown below with two parameters, the first parameter (as detailed in the script inputApp="$1" for information only) is the location and name of the downloaded app (for the default download location "/Applications/Install\ OS\ X\ Mavericks.app" or "/Applications/Install\ OS\ X\ Yosemite.app"), and the second parameter (outputDmg="$2") the location and name of the to be generated dmg file (for example "InstallESD.dmg") as I am running the script from the desktop and I have not specified a location for the outputDmg file it will be created on the desktop:


./CMI.tool /Applications/Install\ OS\ X\ Mavericks.app InstallESD.dmg




./CYI.tool /Applications/Install\ OS\ X\ Yosemite.app InstallESD.dmg


As stated above the current CECI.tool script does not support any additional parameters and therefore will only work if El Capitan has been downloaded to the default location:




The CECI.tool script has the conversion to ISO command but it is marked not to run, as it is not required to do the final conversion for current versions of Workstation and Player, but can be re-enabled if preferred.


The created DMG image is mountable and installs Mavericks (OS X 10.9), Yosemite (OS  10.10) or El Capitan (OS X 10.11) in both Workstation 10/11/12, Player 6/7/8 and ESXi 5.5/6.0, please note these are the only DMG files which can be used as a bootable image in Workstation 10/11/12 and Player 6/7/8. (Please note DMG files extracted from either the Lion or Mountain Lion App Store downloads need to be converted to ISO to work in Workstation 10/11/12 or Player 6/7/8).


Thanks to Donk for the original Create Mavericks Installer script file, and to Shela and JJTagy for the modifications to support Yosemite, and Colt2 for El Capitan support, additional information regarding the script file are available in posts later in this topic.




Edited by MSoK
  • Like 17
Link to comment
Share on other sites

  • 1 month later...

The release of Fusion 7 added support for OS X 10.10 (Yosemite) but required VMware to make a lot of changes to provide acceptable levels of performance for Yosemite as a virtual machine, and even with the changes performance is reduced compared to Mavericks even using the latest VMware Tools from Fusion 8.


JasF has written an app called BeamOff which resolves the performance issues of Yosemite when running as a VMware virtual machine, see link below:




Please note currently BeamOff does not support El Capitan, although some performance increases have been noted using El Capitan with the latest VMware Tools from Fusion 8 compared to Yosemite.


HPReg (VMware employee) has confirmed VMware will include the BeamOff workaround in to the VMware Tools for a future release of Fusion.


Native support for Mavericks (OS X 10.9) is included in VMware Fusion 6 and ESXi 5.5 running on Apple hardware, and once unlocked Workstation 10, Player 6 and ESXi 5.5 but require hardware compatibility set to version 10.


Native support for Yosemite (OS X 10.10) is included in VMware Fusion 7 and ESXi 6 running on Apple hardware, and once unlocked Workstation 11 and Player 7 but require hardware compatibility set to version 11.


Native support for El Capitan (OS X 10.11) is included in VMware Fusion 8 and ESXi 6 running on Apple hardware, and once unlocked Workstation 12 and Player 8 but require hardware compatibility set to version 11 or 12.

Edited by MSoK
  • Like 5
Link to comment
Share on other sites

  • 3 weeks later...

Good morning,


Was trying to get vmware 10 to display "Mac OS X 10.9" but no go.


Was taking a lot of care to install the unlocker correctly.


Any chance someone could share the vmware files, before install? ( That should be a small set of files, including config vmx files and empty hard drive files)




I am a OSX developer and Have a Legal GM, and would like to grab a VM to run on my Windows Machine at work...



Link to comment
Share on other sites

Thanks @MSoK for quick reply, I am running Workstation 10 and it shows 10.8 & 10.9 as well after using unlocker.



Is your InstallESD.iso 10.8.5 or 10.9, if it is 10.8.5 then all should work fine, unless the iso is corrupt in some way. If you are trying to install 10.9 that is not going to work, see the second post in this topic.

  • Like 1
Link to comment
Share on other sites

Thanks again @MSoK, I guess ISO was corrupt and hence not working.

hdiutil trick ISO wasn't working for me and then I found this http://vu1tur.eu.org/tools/


dmg to img worked like charme and I was able to create ISO within two minutes and install was smooth thanks to your tutorial, now I have vanilla OSX 10.8.5 with all updates installed.


One question tho - I am not able to see iTunes and Youtube videos, do I need to change some kext?

  • Like 1
Link to comment
Share on other sites


One question tho - I am not able to see iTunes and Youtube videos, do I need to change some kext?


This required accelerated graphics drivers in OS X.  Unfortunately they do not exist so anything that relies on QE/CI will not work in VMware.

Link to comment
Share on other sites



I have followed these instructions which are great, though after creating the guest OS. I can power on the ISO and launch the setup screen, though when I get to the screen asking where I wish to install Mountain Lion, I cannot see any virtual disks to select and hence this stops my progress.  


I have uploaded picture of the virtual disk configuration and have also tried this with SCSI, IDE & SATA.  I was wondering if you have encountered this.  I am running:

  • Windows 8.1
  • VMWare Workstation 10.0.0 build-1295980;
  • Tried installing guest as Mac OS 10.8 & Mac OS 10.9.




Link to comment
Share on other sites



Before you can install OS X, you need to create an OS X formatted partition, use Disk Utility to do this. I have updated the original post in this thread with instructions for the full OS X installation process, I hope that helps.

Link to comment
Share on other sites



Sorry, one very silly question, you did re-install the Unlocker?


When you upgrade to Workstation 10, older VM's sometimes have a problem, so try updating the Hardware compatibility to Workstation 10.0 virtual machine, rather than the 8 or 9 from earlier versions of Workstation.

Link to comment
Share on other sites

As I said, after redoing .vmx from scratch I have no problems upgrading/running 10.9 GM just fine


The crash is on the shutdown, wonder if the physical CPU is completly not supported by 10.9



Link to comment
Share on other sites



OK, have you tried adding either of the CPUID masks mentioned in the original post, The one I and Donk created is from a Xeon 5520 processor so should work for your 5600 series processor, worth a try. I definitely have OS X 10.9 GM working on a Xeon 5500 series processor, without crashes.

Link to comment
Share on other sites

This is PERFECT!!!! i never thought id see the day id get to use OS X in a VM :'D im sucessfully using Lion 10.7 in VMWare 10 and it installed fine


Thank you so much MSoK!!! :D this tutorial is amazing and the tools by the community cannot be praised enough <3

there are just 4 problems im having with it though, i was hoping perhaps you could help? :/ its the first time ive used a non Windows or Linux sysem in VMWare so these arent common problems for me

1) it cant use shared folders from host even thought ive already set it in the VM's configuration, i dont see a shared folder anywhere in finder or on the desktop

2) it cant connect to the internet at all even though VMWare is set to use NAT, am i doing something wrong here? do i need to install a special driver within OS X to use VMWare's emulated network card or something?

3) resizing the VM's window doesnt always make the guest resize itself to the size of the window, with Windows or Linux guests it always works. 


4) moving an app's window within the VM makes it stutter a bit when you move it around >.< is there a way to fix this?



if its any help my specs are:


Windows 7 x64 (the host that is)

Intel Core i7 2630QM @ 2.00GHz  (with turboboost its 2.9GHz)

8.00 GB RAM

Radeon HD 6770M


ive enebled hardware acceleration and made the VM to use 2GB of RAM, and i gave it one processor with 3 cores in the CPU config of VMWare, any help would be much appreciated!

  • Like 1
Link to comment
Share on other sites

Hi mate,


I can help you with questions 1 & 2.


1. You need to click on Finder, then Preferences and check the box for 'Connected Servers' that will show Shared Folders on the Desktop.


2. You need to set your Network Connection to Bridged for it to work properly under the VM.


I hope this helps.



  • Like 2
Link to comment
Share on other sites



Glad you like the "How To..." and it helped you get up and running with an OS X virtual machine.


As NSCXP2005 has post you can add "VMware Shared Folders" to your desktop, however as I like to keep my desktop uncluttered I prefer to use Go > Computers and "VMware Shared Folders" should be one of the available icons, along with "Network" and your local OS X hard disk(s).


The original post in this thread recommends using Bridged rather than NAT for the network connection.


In terms of Autofit guest and general graphics enhancement, Zenith432 has produced an alternative driver for OS X 10.6 to 10.8 (VMsvga2_v1.2.5_OS_10.6-10.8.pkg) or for OS X 10.9 (VMvsga2_v1.2.5_OS_10.9.pkg) to the VMware one as well as a patch for guest fit (guestd_patches.pkg), see the link below for the files and related topic:






But please be aware 3D graphics and applications that use QE/CI are not supported in an OS X virtual guest.

  • Like 3
Link to comment
Share on other sites

Thank you guys! I finally could find the shared folders of my computer through the VM with your help and with that install OS X apps within it! :D And major thanks for the resolution driver fix! it was so annoying having to scroll with the VM to see the entirety of the screen.


But the network issue still persists, ive set it to bridged and it didnt have any internet access, not even when i ticked the box that says "Replicate physical network connection state" should i configure anything inside OS X to get to connect to VMWare's bridged network? ive attached a screenshot of what the Network Utility app of OS X says.


It shows that its recieved and sent data but i can never get Safari or any other app in it so far to connect to the internet, what do i have to change in the settings to get it to connect? :/ With Windows hosts it doesnt need any configuring


And sorry for replying so late, i was never notified in my email of a response to this thread >.<


Link to comment
Share on other sites

Found something useful in Fusion 6 for Mavericks. If you try to install Mavericks using Fusion 6 it creates an installer image. Having wondered how this was done I found a BASH script in the application package which is used to create a DMG for installation. As it is only a BASH script I think it should be OK to post here, and can be used directly to create a useable installation DMG for other VMware platforms.


# This executable converts a Mavericks .app (which allows to upgrade a machine
# from Mac OS 10.6.7+ to Mavericks) into a Mavericks .dmg (which allows to
# install Mavericks from scratch on a machine).
# It has been tested with "Install OS X 10.9 Developer Preview.app" (build
# 13A476u).

set -x
set -e

# The first argument is the path to the .app bundle (the input of the
# executable).
# The second argument is the path to the .dmg file (the output of the
# executable), which must end with ".dmg".
[ "${outputDmg: -4}" = .dmg ]

# The problem: /System/Installation/Packages inside /BaseSystem.dmg inside
# "$inputApp"/Contents/SharedSupport/InstallESD.dmg is a dangling symlink,
# which prevents installing Mavericks from scratch.
# The solution: Replace the symlink with the /Packages directory inside
# "$inputApp"/Contents/SharedSupport/InstallESD.dmg.

tmpDir=`mktemp -d -t 'Create Mavericks Installer'`

cleanup() {
   if [ -d "$outputMnt" ]; then
      hdiutil detach "$outputMnt"

   if [ -d "$installMnt" ]; then
      hdiutil detach "$installMnt"

   rmdir -- "$tmpDir"

# Cleanup on failure.
trap cleanup ERR

# Mount InstallESD.dmg so we can access /BaseSystem.dmg and /Packages inside.
hdiutil attach "$inputApp"/Contents/SharedSupport/InstallESD.dmg \
   -mountpoint "$installMnt" -nobrowse

# Create "$outputDmg", a read/write copy of the read-only BaseSystem.dmg.
hdiutil convert "$installMnt"/BaseSystem.dmg -format UDRW -o "$outputDmg"

# Enlarge "$outputDmg" to accommodate for our modifications. The UDRW image
# format is not sparse, so we must precisely compute the new size.
curSectors=`hdiutil resize "$outputDmg" -limits | tail -1 | awk '{ print $2 }'`
extraSectors=`BLOCKSIZE=512 du -s -- "$installPkg" | awk '{ print $1 }'`
hdiutil resize "$outputDmg" -sectors $((curSectors + extraSectors))

# Mount "$outputDmg".
hdiutil attach "$outputDmg" -mountpoint "$outputMnt" -nobrowse

# Modify "$outputDmg".
rm -- "$outputPkg"
cp -r -- "$installPkg" "$outputPkg"

# Cleanup on success.
trap ERR; cleanup

ls -alh -- "$outputDmg"
  • Like 5
Link to comment
Share on other sites


  • Create New...