Skip to content

Instantly share code, notes, and snippets.

@bugyt
Last active October 24, 2017 11:07
Show Gist options
  • Save bugyt/3e21b8c2b1586251aa71 to your computer and use it in GitHub Desktop.
Save bugyt/3e21b8c2b1586251aa71 to your computer and use it in GitHub Desktop.
Installing El Capitan in VirtualBox
#!/bin/bash
# Mount the installer image to some directory by using the hdiutil tool
hdiutil attach "/Applications/Install OS X El Capitan.app/Contents/SharedSupport/InstallESD.dmg" -noverify -nobrowse -mountpoint /Volumes/esd
# Now let's create a placeholder image of our ISO file
hdiutil create -o ElCapitan3.cdr -size 7316m -layout SPUD -fs HFS+J
# After an empty ISO file will be created, we need to mount it
hdiutil attach ElCapitan3.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/iso
# Then, we will use asr tool to populate the contents of our new drive
asr restore -source /Volumes/esd/BaseSystem.dmg -target /Volumes/iso -noprompt -noverify -erase
# First of all, remove an invalid link that won't be needed here
rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
# Instead of this link, we need a proper directory, full of package files. We're going to copy this directory from the ESD image that we have mounted few steps earlier.
cp -rp /Volumes/esd/Packages /Volumes/OS\ X\ Base\ System/System/Installation
# We're going to copy some additional installer dependencies as well.
cp -rp /Volumes/esd/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/
cp -rp /Volumes/esd/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/
# After that, we can unmount stuff we don't need anymore:
hdiutil detach /Volumes/esd
hdiutil detach /Volumes/OS\ X\ Base\ System
# Last step is to convert our ISO file into the UDTO format.
hdiutil convert ElCapitan3.cdr.dmg -format UDTO -o ElCapitan3.iso
# Rename .cdr to iso
mv ElCapitan3.iso.cdr ElCapitan3.iso
mv ElCapitan3.iso.cdr ElCapitan3.iso
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment