[HowTo] Create OSX ISO from the OSX Install app

Discussions about using Mac OS X guests (on Apple hardware) in VirtualBox.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

[HowTo] Create OSX ISO from the OSX Install app

Post by socratis »



There's a GUI wrapper for the script, at
https://www.whatroute.net/installerapp2iso.html


WARNING: The script will work with OSX 10.12.4, .5 and .6, 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. If you have any idea on how to make this 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.

The script now works on all OSX installers, from 10.7.x up to 10.15.x.

"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.7 (Lion), 10.8.x (Mountain Lion), 10.9.x (Mavericks), 10.10.x (Yosemite), 10.11.x (El Capitan), 10.12.x (Sierra), 10.13.x (HighSierra), 10.14.x (Mojave) and 10.15.x (Catalina).
  • 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 for the 10.7.x to 10.12.x installers. You don't need to be using "sudo" or being logged in as administrator
  • The script does need administrator access for the 10.13.x to 10.15.x installer.
INSTRUCTIONS
  • Save the zip file, unzip it and run "InstallerApp2ISO.sh" from the Terminal:
  • Code: Select all

    ================================================================================
    Apple OSX Installer Application to ISO creation tool
    ================================================================================
    Version: 2019-11-27
    Copyright (C) 2017-2019, socratis @ VirtualBox forums,
             with help from granada29 @ VirtualBox forums.
    All rights reserved.
    
    
    Usage:
    
       InstallerApp2ISO  -i|--installer <InstallerApp>
                        [-o|--output <OutputDir>]
                        [-t|--tmpdir <TempDir>]
                        [-v|--verbose <VerboseLevel>]
                        [-d|--dry-run]
                        [-p|--privileged <AltSudo>]
                        [-x|--OSX <OSXVersion>]
                        [-y|--yes]
                        [-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.
    
    -p|--privileged Command to use if 'sudo' is not available
    
    -x|--OSX        OSXVersion can be one of the following strings:
                    '10.7', '10.8', '10.9', '10.10', '10.11', '10.12', '10.13',
                    '10.14', '10.15'.
                    You should use it in case that the OSX version cannot be
                    determined automatically, *OR* if you're running a dry run.
    
    -y|--yes        Proceed without prompting user
    
    -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.
  • NOTES for 10.13.x to 10.15.x: 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.
RELEASES

2019-11-27
  • Added support for 10.15.1, 10.15.2.
  • Disable Spotlight before unmounting sparse image.
  • Fixed an issue when running administrator tasks from within the app.
2019-08-25
  • Added support for 10.14.6.
  • Added support for 10.7.
2019-06-05
  • Added support for up to 10.15.beta and beyond.
  • When using the dry-run simply check for the existence of the installer. Do not check for the available free space or the output/temp directory, since no actual conversion will take place.
2019-05-28
  • Small fixes for the 3rd party authentication.
  • Change the 'if' statements style from 'test' to '[]'.
2019-05-26 (granada29 version) 2019-01-04
  • Added support for 10.14.2 (18C54).
  • Added support for (hopefully) all 10.8.x.
  • Added host OSX version information.
2018-08-16
  • Added support for 10.13.6 (17G65).
2018-06-10
  • Added support for 10.13.5 (17F77).
  • Added support for 10.14 beta (18A293u).
2018-04-18 (Dim version)
  • Finally unified the 10.9-10.13 scripts!
    Unfortunately the 10.13 scripts require 'admin' group membership.
  • Removed the "--checksum" option. It never worked to begin with.
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.
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
2019-11-27
(9.1 KiB) Downloaded 1696 times
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
ChipMcK
Volunteer
Posts: 1095
Joined: 20. May 2009, 02:17
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Windows, OSX
Location: U S of A

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

Post by ChipMcK »

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.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

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

Post by socratis »

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 ;)
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

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

Post by socratis »

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...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
ChipMcK
Volunteer
Posts: 1095
Joined: 20. May 2009, 02:17
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Windows, OSX
Location: U S of A

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

Post by ChipMcK »

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

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 705 times
InstallerApp2iso_00.log.zip
Quoted file name
(3.95 KiB) Downloaded 888 times
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

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

Post by socratis »

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...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
ChipMcK
Volunteer
Posts: 1095
Joined: 20. May 2009, 02:17
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Windows, OSX
Location: U S of A

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

Post by ChipMcK »

MacBook Air (13inch, Mid 2013) for accessing iMac (20inch, Mid 2007) via BTMM
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

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

Post by socratis »

ChipMcK wrote:Also, icon view of OS X Base System is open during . . .

Code: Select all

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...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

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

Post by socratis »

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

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

Post by socratis »

Update: new version 2017-05-17 is out.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
talltraveler
Posts: 1
Joined: 7. Jun 2017, 19:15

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

Post by talltraveler »

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.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

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

Post by socratis »

Glad it helped you! I will ChEcK tHe CaSe of the help.
And I really hate not having your Mac :D
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
IOOI
Posts: 74
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

Post by IOOI »

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

================================================================================
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: 74
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

Post by IOOI »

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
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

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

Post by socratis »

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.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Post Reply