Skip to content

Instantly share code, notes, and snippets.

@kevin-smets
Forked from ryanmaclean/el_capitan_dmg_virtualbox.sh
Last active October 22, 2023 13:01
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save kevin-smets/af86eaecc17808ce1ed3 to your computer and use it in GitHub Desktop.
Save kevin-smets/af86eaecc17808ce1ed3 to your computer and use it in GitHub Desktop.
Convert macOS installer for use in VirtualBox
#!/bin/bash
# Disclaimer: never got this to work properly and have not attempted it since.
# This will require about 30GB of space, still in experimental phase right now
sudo gem install iesd
cd /Applications # Or wherever you hve the "Install 10.12 Developer Preview.app" available
iesd -i Install\ 10.12\ Developer\ Preview.app -o macos.dmg -t BaseSystem
hdiutil convert macos.dmg -format UDSP -o macos.sparseimage
# You can cloase any popup finder windows
hdiutil mount Install\ 10.12\ Developer\ Preview.app/Contents/SharedSupport/InstallESD.dmg
hdiutil mount macos.sparseimage
cp /Volumes/OS\ X\ Install\ ESD/BaseSystem.* /Volumes/OS\ X\ Base\ System/
# We use the finder to eject here, based on this OSX Daily tip
# http://osxdaily.com/2014/05/22/eject-all-mounted-volumes-command-line-mac/
osascript -e 'tell application "Finder" to eject (every disk whose ejectable is true)'
hdiutil convert macos.sparseimage -format UDZO -o macos_vm.dmg
# You can now delete any of the original resources if you no longer need them
rm -rf macos.dmg
rm -rf macos.sparseimage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment