[Howto] Create OSX ISO from the OSX Install app

Discussions about using Mac OS X guests (on Apple hardware) in VirtualBox.

[Howto] Create OSX ISO from the OSX Install app

Postby socratis » 16. Jan 2017, 20:58


WARNING: The script will work with OSX ≥ 10.12.4, but VirtualBox will *not* boot from such an ISO for reasons yet unknown. There is a bug report open for that: #16644: Installation of clean OSX 10.12.4 fails.

The script will *not* work with 10.13.x, since the OSX 10.13 installer is not a standalone one, but rather a stub that downloads the rest of the components on the fly.

If you have any idea on how to make these two cases work, I'd appreciate a comment.


With OSX 10.9 (Mavericks) Apple started distributing the OSX installer as a standalone application, with instructions on how to create bootable USB sticks if needed. The problem is that this is not ideal for users of VirtualBox who wanted to install a clean VM from scratch, or (until VirtualBox 5.1) could not boot their VM from a bootable USB.

There are two parts in this tutorial: 1) OSX 10.9 up to 10.12, and 2) OSX 10.13.

Part 1: OSX 10.9 up to 10.12

"InstallerApp2ISO.sh" creates an ISO file from the various OSX installer applications that Apple distributes (freely) to existing OSX users:
  • This is my first attempt at bash scripting, so please go easy on me. If you have any suggestions, feel free (if not obliged) to share your thoughts.
  • If you encounter an error, re-run the script with the extra verbose option "-v 3", copy the whole Terminal output and post it here with as many details as possible (besides the output that is).
  • The script is not portable, as it uses some OSX only options. It could be, but it would miss all the ... special effects.
  • You'll need 15 GB of free space for that. Most of the time less, but let's be conservative. And if you don't have 15 GB available, the script is the least of your problems.
  • The script covers versions 10.9.x (Mavericks), 10.10.x (Yosemite), 10.11.x (El Capitan) and 10.12.x (Sierra).
  • The script will leave you with an ISO image named "10.#(.#).iso", where # is... well, you can guess.
  • The script does not need administrator access. You don't need to be using "sudo" or being logged in as administrator.

INSTRUCTIONS
    Save the zip file, unzip it and run "InstallerApp2ISO.sh" from the Terminal:
================================================================================
Apple OSX Installer Application to ISO creation tool
================================================================================
Version: 2017-07-18
Copyright (C) 2017, socratis @ VirtualBox forums.
All rights reserved.

*** ERROR: No arguments specified. The --installer option is mandatory.

Usage:

InstallerApp2ISO -i|--installer <InstallerApp>
[-o|--output <OutputDir>]
[-t|--tmpdir <TempDir>]
[-v|--verbose <VerboseLevel>]
[-d|--dry-run]
[-x|--OSX <OSXVersion>]
[-c|--checksum]
[-r|--revision]
[-h|-?|--help]

-i|--installer The full path of the InstallerApp. *** MANDATORY ***

-o|--output The directory where the resulting ISO will be created.
The name will be 10.x.y.iso. Default is your desktop.
The directory will be checked for free space availability.

-t|--tmpdir If you are running low on space, you can provide an
alternative temporary/scratch directory. The directory
will be checked for free space availability.
*******************************************************
***** DO NOT CHOOSE A NETWORK TEMPORARY DIRECTORY *****
*******************************************************

-v|--verbose Some OSX commands support --verbose and --quiet options.
In addition, the verbose level can control whether the
the commands are printed before they are executed:
0: Set the quiet flag in OSX. Commands are not printed.
1: Set no flags in OSX. Commands are not printed. DEFAULT.
2: Set no flags in OSX. Commands are printed.
3: Set the verbose flag in OSX. Commands are printed.

-d|--dry-run Doesn't actually run the scripts, simply output the
commands that would be used with the given parameters.

-x|--OSX OSXVersion can be one of: 10.9, 10.10, 10.11 or 10.12.
You should use it in case that the OSX version cannot
be determined automatically, or you're running a dry run.

-c|--checksum Compare the output of the generated ISO with a list of
known checksums. Optional, but useful.

-r|--revision Print the revision history of the script.

-h|-?|--help Print this help message.


KNOWN ISSUES
  • A network temporary directory will corrupt your ISO. I've been trying to figure out why, to no avail. I'm planning on including a check on whether the temporary directory is on a network volume or not.
  • The checksum option is not working as expected. This is the most baffling part in the behavior of the script. You have a script that does the exact same thing, time after time after time. Yet the checksum at the end is like you're generating a random hex number. No clue why it doesn't work.
  • Error checking ranges from non existent to not at all. I mean it will definitely fail in the first error encounter, I simply don't do any error redirection/logging.

RELEASES
2017-07-25
  • When using the dry-run it doesn't check for anything anymore. Not the existence of the installer nor the available free space.
  • Trimming of the free space from the sparsebundle is back.
2017-06-18
  • Fixed an issue where if the destination volume contained a space, the calculation for the amount of free space generated an error.
  • Fixed inconsistencies in ISO vs iso.
2017-05-17
  • Updated to cover OSX 10.12.5 (16F73).
  • Fixed verbosity flags for some cases.
2017-04-02
  • Updated to cover OSX 10.12.4 (16E195).
  • The '--OSX' flag was ignored if the '--dry-run' was not set as well. Now you can use future OSX updates even if the script doesn't cover them.
  • Fixed a cosmetic error if the verbose level was set to 2 or 3.
  • Fixed a cosmetic error by closing the 'OSX Base System' window.
  • Added version and revision information.
2017-03-01
  • Initial release. Unified pretty much the scripts for different versions of the InstallerApps. Added a few options here and there.


Part 2: OSX 10.13

    • Download "Install macOS High Sierra.app" from Apple. By default it will be placed in the "/Applications" folder. If the upgrade starts, cancel out.
    • Run the script below as an Administrator, courtesy of https://tylermade.net/2017/10/05/how-to ... installer/
      hdiutil create -o /tmp/10.13.x.cdr -size 5530m -layout SPUD -fs HFS+J
      hdiutil attach /tmp/10.13.x.cdr.dmg -noverify -mountpoint /Volumes/1013_install
      sudo /Applications/Install\ macOS\ High\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/1013_install
      mv /tmp/10.13.x.cdr.dmg /Users/Shared/10.13.x.dmg
      hdiutil detach /Volumes/Install\ macOS\ High\ Sierra
      hdiutil convert /Users/Shared/10.13.x.dmg -format UDTO -o /Users/Shared/10.13.x
      rm /Users/Shared/10.13.x.dmg
      mv /Users/Shared/10.13.x.cdr /Users/Shared/10.13.x.iso
NOTE: The script will not work if you are a Standard user. You have to be an Administrator in order for the "sudo" to work, since Standard users cannot sudo. If you are a Standard user, first do a "su Administrator" before running the script.

Installing OSX 10.13 is not a straight forward process, so I'll cover it in another article, "[HowTo] Install OSX 10.13 in a VM".

Attachments
InstallerApp2ISO.sh.zip
2017-07-25
(7.38 KiB) Downloaded 325 times
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
socratis
Site Moderator
 
Posts: 12649
Joined: 22. Oct 2010, 11:03
Location: Greece
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5

Re: [Howto] Create OSX ISO from the OSX Install app

Postby ChipMcK » 16. Feb 2017, 01:21

Most people are lazy.

But any application from the macOSX App Store does not have to reside in Folder /Applications.
MacOSX allows them to be moved to a subFolder of /Applications.
App Store is perfectly happy updating them while residing in any Folder, including on an external drive.

Personally I assign tag 'MAS' to the applications and move all tagged 'MAS' to a subFolder.
This cleans up some clutter in Folder /Applications.

So, consider a variable for the 'default' location of the installer application.
ChipMcK
Volunteer
 
Posts: 961
Joined: 20. May 2009, 02:17
Location: U S of A
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Windows, OSX

Re: [Howto] Create OSX ISO from the OSX Install app

Postby socratis » 16. Feb 2017, 01:31

ChipMcK wrote:So, consider a variable for the 'default' location of the installer application.
socratis wrote:Yes, it could have been a single script that covers all installers. Yes, it could use inputs for the installer location and the ISO output. Yes, it could do some checking for HD space. Yes, it could figure out the differences between the installers and take appropriate actions. Well... I got bored. Maybe in version 0.2.

Since I feel a little bit insomniac today (it's already 01:30 and I'm watching Champions League, Real-Napoli), I might try to work on those points in parallel. I've had it in the back of my mind for some time, but I guess i needed the push ;)
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
socratis
Site Moderator
 
Posts: 12649
Joined: 22. Oct 2010, 11:03
Location: Greece
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5

Re: [Howto] Create OSX ISO from the OSX Install app

Postby socratis » 1. Mar 2017, 08:58

ChipMcK wrote:So, consider a variable for the 'default' location of the installer application.
ChipMcK, I hope you like them options... ;)

Initial version is out. It would have been way sooner if it wasn't for the temporary_dir corruptions (#%@^!) and the checksum (Look honey, I just discovered a new random number generator!). Anyway, give it a shot and let me know...
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
socratis
Site Moderator
 
Posts: 12649
Joined: 22. Oct 2010, 11:03
Location: Greece
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5

Re: [Howto] Create OSX ISO from the OSX Install app

Postby ChipMcK » 1. Mar 2017, 23:44

Seems to work, but I'm getting Bash error line 602: [: too many arguments

Two logs attached

Also, icon view of OS X Base System is open during . . .
Code: Select all   Expand viewCollapse view
Remove Package link and replace with actual files... (go get some coffee)
  *** TIP *** You can press 'Ctrl-T' to watch the copying progress...
--------------------------------------------------------------------------------
rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
cp -rp /Volumes/InstallESD/Packages /Volumes/OS\ X\ Base\ System/System/Installation/
cp -rp /Volumes/InstallESD/BaseSystem.* /Volumes/OS\ X\ Base\ System/

Some might object.
Attachments
InstallerApp2iso_01.log
UnQuoted flie name
(18.96 KiB) Downloaded 14 times
InstallerApp2iso_00.log.zip
Quoted file name
(3.95 KiB) Downloaded 9 times
ChipMcK
Volunteer
 
Posts: 961
Joined: 20. May 2009, 02:17
Location: U S of A
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Windows, OSX

Re: [Howto] Create OSX ISO from the OSX Install app

Postby socratis » 2. Mar 2017, 00:20

OK, got it. I really don't know how that one got away. That's why they're called bugs :shock:
Wrong:      if [ $MY_VERBOSE -2e "2" -o $MY_DRYRUN -ne "0" ]; then
Correct: if [ $MY_VERBOSE -ne "2" -o $MY_DRYRUN -ne "0" ]; then
You can update your script locally, line # 602. I'll also update it in the OP. Actually, come to think of it, I'll put another field in there, the script version/date. That would definitely help in the debugging.

Thanks for the feedback!!!



PS. Bloody hell!
Conversion script took a total of : 2 min, 3 sec (123 s).
The best time I've ever gotten was 12 min! For local conversion!!! Don't even get me started when I was testing the network functionality...
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
socratis
Site Moderator
 
Posts: 12649
Joined: 22. Oct 2010, 11:03
Location: Greece
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5

Re: [Howto] Create OSX ISO from the OSX Install app

Postby ChipMcK » 2. Mar 2017, 02:34

MacBook Air (13inch, Mid 2013) for accessing iMac (20inch, Mid 2007) via BTMM
ChipMcK
Volunteer
 
Posts: 961
Joined: 20. May 2009, 02:17
Location: U S of A
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Windows, OSX

Re: [Howto] Create OSX ISO from the OSX Install app

Postby socratis » 2. Mar 2017, 09:17

ChipMcK wrote:Also, icon view of OS X Base System is open during . . .
Code: Select all   Expand viewCollapse view
cp -rp /Volumes/InstallESD/Packages /Volumes/OS\ X\ Base\ System/System/Installation/
cp -rp /Volumes/InstallESD/BaseSystem.* /Volumes/OS\ X\ Base\ System/

Some might object.

Yes, I know, I hate it too. It's like I didn't specifically told the script to NOT do that:
#588: hdiutil attach "$MY_TEMPDIR/$MY_OSXVERSION.sparseimage" -noverify \
-nobrowse -mountpoint /Volumes/OS\ X\ Base\ System $MY_VERBOSECMD

The problem is that the "-nobrowse" is honored, up to the "cp" point, where I can't interrupt it. As soon as the "cp" kicks in, the Finder window appears. And only for 10.11, 10.12 installers, mind you. Oh, the beauty of compatibility...

Maybe I'll try to think of a workaround, something like copying a small file, which will force the "evil" to show its "face", at which point I can AppleScript kill it and then proceed with the proper, full copy. Unless of course we're talking about Hydra...
...and for every head chopped off, the Hydra would regrow a couple of heads...
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
socratis
Site Moderator
 
Posts: 12649
Joined: 22. Oct 2010, 11:03
Location: Greece
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5

Re: [Howto] Create OSX ISO from the OSX Install app

Postby socratis » 2. Apr 2017, 16:20

Update: new version 2017-04-02 is out.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
socratis
Site Moderator
 
Posts: 12649
Joined: 22. Oct 2010, 11:03
Location: Greece
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5

Re: [Howto] Create OSX ISO from the OSX Install app

Postby socratis » 17. May 2017, 11:27

Update: new version 2017-05-17 is out.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
socratis
Site Moderator
 
Posts: 12649
Joined: 22. Oct 2010, 11:03
Location: Greece
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5

Re: [Howto] Create OSX ISO from the OSX Install app

Postby talltraveler » 7. Jun 2017, 19:27

Many, many thanks for this!
- There is a typo in the help message: "InstallerApp2ISO" should be "InstallerApp2iso" (not significant!!)
- Just for information, on a 2015 Macbook pro with adequate memory and a flash drive the script required only 82 seconds.
talltraveler
 
Posts: 1
Joined: 7. Jun 2017, 19:15

Re: [Howto] Create OSX ISO from the OSX Install app

Postby socratis » 7. Jun 2017, 19:32

Glad it helped you! I will ChEcK tHe CaSe of the help.
And I really hate not having your Mac :D
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
socratis
Site Moderator
 
Posts: 12649
Joined: 22. Oct 2010, 11:03
Location: Greece
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5

Re: [Howto] Create OSX ISO from the OSX Install app

Postby IOOI » 15. Jun 2017, 00:28

I did run this script on a 10.10.5 host. All went fine so far besides some more or less cosmetic error messages:

Code: Select all   Expand viewCollapse view
================================================================================
Apple OSX Installer Application to ISO creation tool
================================================================================
Version: 2017-05-17
Copyright (C) 2017, socratis @ VirtualBox forums.
All rights reserved.

./InstallerApp2iso.sh: line 316: 65%: syntax error: operand expected (error token is "%")
./InstallerApp2iso.sh: line 317: [: 65%: integer expression expected
- OSX version: attempting automatic OSX detection from the InstallerApp...
/dev/disk5             GUID_partition_scheme             
/dev/disk5s1           EFI                               
/dev/disk5s2           Apple_HFS                         /Volumes/InstallESD
- OSX version detected: 10.12 (16A323)
"disk6" unmounted.
"disk6" ejected.
"disk5" unmounted.
"disk5" ejected.
--------------------------------------------------------------------------------
The conversion will use the following parameters:
    - Installer application   : Install macOS Sierra.app
./InstallerApp2iso.sh: line 494: 65%*1024*1024/1000/1000: syntax error: operand expected (error token is "*1024*1024/1000/1000")
    - Temporary directory     : /tmp (63 GiB/66 GB free)
    - OSX version scripts     : 10.11/10.12 scripts for version 10.12 (16A323)
    - Verbosity level         : 1
    - Calculate ISO checksum  : 0
    - Dry-run cmd. output     : 0

************************   I M P O R T A N T   ************************
Please understand that there is feedback for most processes, but not
for all of them, such as copying and moving. They can take up to ten
minutes or more, depending on your HD speed. If you selected a network
location or an external HD, these times can vary a lot.
***********************************************************************

Continue? (Yes/No)
yes


Conversion script started on: 2017-06-14 23:58:24 CEST
--------------------------------------------------------------------------------

Mount the installer image...
--------------------------------------------------------------------------------
/dev/disk5             GUID_partition_scheme             
/dev/disk5s1           EFI                               
/dev/disk5s2           Apple_HFS                         /Volumes/InstallESD
29:60: execution error: Finder got an error: Can’t get window "OS X Install ESD". (-1728)

Create 10.12 blank ISO image with a Single Partition - Apple Partition Map...
--------------------------------------------------------------------------------
created: /tmp/10.12.sparseimage

Mount the sparse bundle for package addition...
--------------------------------------------------------------------------------
/dev/disk6             Apple_partition_scheme            
/dev/disk6s1           Apple_partition_map               
/dev/disk6s2           Apple_HFS                         /Volumes/OS X Base System

Restore the Base System into the 10.12 ISO image...
--------------------------------------------------------------------------------
   Validating target...done
   Validating source...done
   Retrieving scan information...done
   Validating sizes...done
   Restoring  ....10....20....30....40....50....60....70....80....90....100
   Remounting target volume...done
33:66: execution error: Finder got an error: Can’t get window "OS X Base System". (-1728)

Remove Package link and replace with actual files... (go get some coffee)
  *** TIP *** You can press 'Ctrl-T' to watch the copying progress...
--------------------------------------------------------------------------------

Unmount the installer image...
--------------------------------------------------------------------------------
"disk5" unmounted.
"disk5" ejected.

Unmount the sparse bundle...
--------------------------------------------------------------------------------
"disk6" unmounted.
"disk6" ejected.

Convert the sparse bundle to ISO/CD master... (this could take until next year)
--------------------------------------------------------------------------------
Driver Descriptor Map (DDM : 0) lesen …
Apple (Apple_partition_map : 1) lesen …
disk image (Apple_HFS : 2) lesen …
...............................................................................
Dauer:  1m 20.602s
Geschwindigkeit: 101.6M Byte/s
Ersparnis: 0.0 %
created: /tmp/10.12.cdr

Remove the sparse bundle...
--------------------------------------------------------------------------------

Rename the ISO and move it to its destination...
This can take a * really * long time if the destination is on the network...
--------------------------------------------------------------------------------
mv: ./10.12.iso: set owner/group (was: 501/0): Operation not permitted

Conversion script ended at         : 2017-06-15 00:03:20 CEST
Conversion script took a total of  : 4 min, 55 sec (295 s).
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
!!!  DONE !!!
--------------------------------------------------------------------------------
You can find the OSX 10.12 installation DVD in:
./10.12.iso


MBP15:Mac OS X Installer lars$
IOOI
 
Posts: 48
Joined: 14. Nov 2014, 18:54
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: OPENSTEP, Mac OS X, FreeBSD, Windows

Re: [Howto] Create OSX ISO from the OSX Install app

Postby IOOI » 15. Jun 2017, 00:41

Have you followed the discussion here: https://github.com/geerlingguy/macos-vi ... /issues/24 ?

Especially the comment by tcurdt contains a script that approaches things differently, it uses the command line installer to do an install onto a sparse image and convert this into a .vdi

brki postet this link to a script which he claim he found to be working with 10.12.5: https://github.com/jonanh/osx-vm-templa ... ualbox-ovf I had a look at the scripts in this repo and while huge and complex it seems also to take the command line installer approach.

Hope I found some new ideas for the 10.12.5 problem
IOOI
 
Posts: 48
Joined: 14. Nov 2014, 18:54
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: OPENSTEP, Mac OS X, FreeBSD, Windows

Re: [Howto] Create OSX ISO from the OSX Install app

Postby socratis » 15. Jun 2017, 00:46

Yes, I've been following that as well. But that's not a solution, that's a workaround at best. Problem is the VirtualBox is unable to start a VM with a native 10.12.5. But this is not the thread for such a discussion, no? There are at least two more dedicated threads about this.

Now, to your error. I need to see the exact command line. Something about your destination directory is not right.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
socratis
Site Moderator
 
Posts: 12649
Joined: 22. Oct 2010, 11:03
Location: Greece
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5

Next

Return to Mac OS X Guests

Who is online

Users browsing this forum: No registered users and 2 guests