Skip to content

Instantly share code, notes, and snippets.

@janodev
Created August 3, 2016 10:11
Show Gist options
  • Save janodev/7425aa32a3f4a40630fcf854d63b27c5 to your computer and use it in GitHub Desktop.
Save janodev/7425aa32a3f4a40630fcf854d63b27c5 to your computer and use it in GitHub Desktop.
Install El Capitan on a Virtual Box image
#!/bin/bash
# Mount the Installer image
hdiutil attach /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
# Create El Capitan sparseimage of 7316mb with a Single Partition - Apple Partition Map
hdiutil create -o /tmp/ElCapitan -size 7316m -layout SPUD -fs HFS+J -type SPARSE
# Mount the El Capitan sparseimage
hdiutil attach /tmp/ElCapitan.sparseimage -noverify -nobrowse -mountpoint /Volumes/install_build
# Restore the Base System into the El Capitan Blank sparseimage
asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
# Remove Packages link and replace with actual files
rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
cp -rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/
# Copy El Capitan installer dependencies
cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist
cp -rp /Volumes/install_app/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/BaseSystem.dmg
# Unmount the installer image
hdiutil detach /Volumes/install_app
# Unmount the Base System image
hdiutil detach /Volumes/OS\ X\ Base\ System/
# Optimise Sparseimage Size
hdiutil compact /tmp/ElCapitan.sparseimage
hdiutil resize -size min /tmp/ElCapitan.sparseimage
# Convert the ElCapitan spareseimage to ISO/CD master
hdiutil convert /tmp/ElCapitan.sparseimage -format UDTO -o /tmp/ElCapitan.iso
# Rename the ElCapitan ISO image and move it to the desktop
mv /tmp/ElCapitan.iso.cdr ~/Desktop/'EC 10.11.0.iso'
# Delete ElCapitan.sparseimage file
rm -f /tmp/ElCapitan.sparseimage
echo Open VirtualBox
echo 1. Create a new OS, Type: Mac OS X, Version: OS X 10.11 El Capitan 64-bit. [x] “Create a virtual hard disk now”
echo 2. In System, change "System->chipset" to PIIX3, mount created ISO and boot up.
echo 3. Start the VM, use the image you created before.
echo 4. When the Installer boots, choose "Utilities > Disk Utility" to format your virtual hard drive as a HFS+ Journaled disk.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment