Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Simple bash script to create a Bootable ISO from macOS Sierra Install Image from Mac App Store
#!/bin/bash
#
# Credits to fuckbecauseican5 from https://www.reddit.com/r/hackintosh/comments/4s561a/macos_sierra_16a238m_install_success_and_guide/
# Adapted to work with the official image available into Mac App Store
#
# Enjoy!
hdiutil attach /Applications/Install\ macOS\ Sierra.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
hdiutil create -o /tmp/Sierra.cdr -size 7316m -layout SPUD -fs HFS+J
hdiutil attach /tmp/Sierra.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/install_build
asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
cp -rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/
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
hdiutil detach /Volumes/install_app
hdiutil detach /Volumes/OS\ X\ Base\ System/
hdiutil convert /tmp/Sierra.cdr.dmg -format UDTO -o /tmp/Sierra.iso
mv /tmp/Sierra.iso.cdr ~/Desktop/Sierra.iso
@dispera

This comment has been minimized.

Show comment Hide comment
@dispera

dispera Nov 29, 2016

Nice, thanks!

I suggest to add a line to remove a leftover file:
rm /tmp/Sierra.cdr.dmg

It could be after line 18 :)

dispera commented Nov 29, 2016

Nice, thanks!

I suggest to add a line to remove a leftover file:
rm /tmp/Sierra.cdr.dmg

It could be after line 18 :)

@defender4github

This comment has been minimized.

Show comment Hide comment
@defender4github

defender4github Dec 11, 2016

o yea thank you, i have discovered the answer, but that s weird because, i dont have mac system to implement the bash code. hmm, is there any other method round this?

o yea thank you, i have discovered the answer, but that s weird because, i dont have mac system to implement the bash code. hmm, is there any other method round this?

@jbrydges01

This comment has been minimized.

Show comment Hide comment
@jbrydges01

jbrydges01 Dec 20, 2016

Thanks! this was a huge help

Thanks! this was a huge help

@chqiwang

This comment has been minimized.

Show comment Hide comment
@chqiwang

chqiwang Dec 28, 2016

Thank you! It helps me a lot!

Thank you! It helps me a lot!

@leomoon

This comment has been minimized.

Show comment Hide comment
@leomoon

leomoon Jan 3, 2017

THANK YOU!

leomoon commented Jan 3, 2017

THANK YOU!

@Jolly-Pirate

This comment has been minimized.

Show comment Hide comment
@Jolly-Pirate

Jolly-Pirate Mar 1, 2017

I was using another script that worked fine with 10.9/10.10/10.11 but somehow not for Sierra, even though I edited the pathnames properly. This worked perfectly and I can install the Sierra iso in VMWare.

I was using another script that worked fine with 10.9/10.10/10.11 but somehow not for Sierra, even though I edited the pathnames properly. This worked perfectly and I can install the Sierra iso in VMWare.

@Zeimin

This comment has been minimized.

Show comment Hide comment
@Zeimin

Zeimin Mar 20, 2017

Thank you! Worked like a charm. If you run into the issue where the first line ends with Resource busy you just need to unmount the Sierra install image in diskutil.

Zeimin commented Mar 20, 2017

Thank you! Worked like a charm. If you run into the issue where the first line ends with Resource busy you just need to unmount the Sierra install image in diskutil.

@duffyjp

This comment has been minimized.

Show comment Hide comment
@duffyjp

duffyjp Apr 7, 2017

I used this to create a bootable USB. Just dd the result Sierra.iso as usual, works like a charm. I previously tried two GUI apps "Install Disk Creator" and "DiskMaker X 6" but both had issues.

duffyjp commented Apr 7, 2017

I used this to create a bootable USB. Just dd the result Sierra.iso as usual, works like a charm. I previously tried two GUI apps "Install Disk Creator" and "DiskMaker X 6" but both had issues.

@trevorgithub

This comment has been minimized.

Show comment Hide comment
@trevorgithub

trevorgithub Apr 10, 2017

I tried running the above commands, but this line:

hdiutil create -o /tmp/Sierra.cdr -size 7316m -layout SPUD -fs HFS+J

failed for me with the error message:

hdiutil: create failed - No space left on device

Any suggestions?

Note, I'm trying to run this code on OS X Lion.

I tried running the above commands, but this line:

hdiutil create -o /tmp/Sierra.cdr -size 7316m -layout SPUD -fs HFS+J

failed for me with the error message:

hdiutil: create failed - No space left on device

Any suggestions?

Note, I'm trying to run this code on OS X Lion.

@m1keil

This comment has been minimized.

Show comment Hide comment
@m1keil

m1keil Apr 14, 2017

@trevorgithub you don't have enough disk space left

Huge thanks to the author.. saved me hours!

m1keil commented Apr 14, 2017

@trevorgithub you don't have enough disk space left

Huge thanks to the author.. saved me hours!

@adtraub

This comment has been minimized.

Show comment Hide comment
@adtraub

adtraub Apr 16, 2017

Worked like a charm! Well done.

adtraub commented Apr 16, 2017

Worked like a charm! Well done.

@pakx

This comment has been minimized.

Show comment Hide comment
@pakx

pakx Apr 19, 2017

Unfortunately I still get the VirtualBox message that originally brought me here: "FATAL: No bootable medium found! System halted!"

PS: I'm trying to create a bootable Yosemite.iso from Yosemite.app for VirtualBox on a Mac host.

pakx commented Apr 19, 2017

Unfortunately I still get the VirtualBox message that originally brought me here: "FATAL: No bootable medium found! System halted!"

PS: I'm trying to create a bootable Yosemite.iso from Yosemite.app for VirtualBox on a Mac host.

@seanthewebber

This comment has been minimized.

Show comment Hide comment
@seanthewebber

seanthewebber May 1, 2017

Howdy all, I am attempting to install a guest operating system in VMware Workstation from Sierra.iso. However, it spits back the following error:

screenshot from 2017-04-30 23-41-56

This file is not a valid disc image. Please make sure you have selected the correct file.

Does anyone know why VMware is rejecting the ISO file? @budwig?

Howdy all, I am attempting to install a guest operating system in VMware Workstation from Sierra.iso. However, it spits back the following error:

screenshot from 2017-04-30 23-41-56

This file is not a valid disc image. Please make sure you have selected the correct file.

Does anyone know why VMware is rejecting the ISO file? @budwig?

@danielgindi

This comment has been minimized.

Show comment Hide comment
@danielgindi

danielgindi Jun 5, 2017

@seanthewebber Have you ran the unlocker for unlocking macOS on VMWare?

Btw, everyone, you can run bash <(curl -s https://gist.githubusercontent.com/julianxhokaxhiu/6ed6853f3223d0dd5fdffc4799b3a877/raw/b56a93d8523b132c0a156b968263a5814b2dab90/create-iso.sh) to install this script without downloading ;-)

@seanthewebber Have you ran the unlocker for unlocking macOS on VMWare?

Btw, everyone, you can run bash <(curl -s https://gist.githubusercontent.com/julianxhokaxhiu/6ed6853f3223d0dd5fdffc4799b3a877/raw/b56a93d8523b132c0a156b968263a5814b2dab90/create-iso.sh) to install this script without downloading ;-)

@fiery-

This comment has been minimized.

Show comment Hide comment
@fiery-

fiery- Jun 6, 2017

Any idea how to create macOS 10.13 beta iso from the installation app?

BaseSystem.dmg/.chunklist are outside the InstallESD.dmg. But even if I use them, an error that OSInstall.mpkg is damaged, appears at High Sierra installation.

fiery- commented Jun 6, 2017

Any idea how to create macOS 10.13 beta iso from the installation app?

BaseSystem.dmg/.chunklist are outside the InstallESD.dmg. But even if I use them, an error that OSInstall.mpkg is damaged, appears at High Sierra installation.

@sashimiman

This comment has been minimized.

Show comment Hide comment
@sashimiman

sashimiman Jun 6, 2017

watching for correct commands for the latest high sierra beta too :)

watching for correct commands for the latest high sierra beta too :)

@fiery-

This comment has been minimized.

Show comment Hide comment
@fiery-

fiery- Jun 7, 2017

For High Sierra iso, I tried to put BaseSystem.dmg at "/System/Installation/Packages/" or at "/" as shown above, but the same error appears: OSInstall.mpkg is damaged (since it can't find BaseSystem.dmg).
screen shot 2017-06-08 at 01 12 01

Pacifist gives the following error when opening InstallESD.dmg.
screen shot 2017-06-08
Update: I managed to install High Sierra as an update to Sierra in VirtualBox. This blog helped me a lot.

I'm still curious how to create iso for High Sierra, though.

fiery- commented Jun 7, 2017

For High Sierra iso, I tried to put BaseSystem.dmg at "/System/Installation/Packages/" or at "/" as shown above, but the same error appears: OSInstall.mpkg is damaged (since it can't find BaseSystem.dmg).
screen shot 2017-06-08 at 01 12 01

Pacifist gives the following error when opening InstallESD.dmg.
screen shot 2017-06-08
Update: I managed to install High Sierra as an update to Sierra in VirtualBox. This blog helped me a lot.

I'm still curious how to create iso for High Sierra, though.

@agentsim

This comment has been minimized.

Show comment Hide comment

agentsim commented Jun 10, 2017

@raxim1

This comment has been minimized.

Show comment Hide comment
@raxim1

raxim1 Aug 6, 2017

It hangs at IOConsoleUsers: getIOScreenLockState

raxim1 commented Aug 6, 2017

It hangs at IOConsoleUsers: getIOScreenLockState

@sntulix

This comment has been minimized.

Show comment Hide comment
@sntulix

sntulix Oct 28, 2017

Thank you.

sntulix commented Oct 28, 2017

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment