Skip to content

Commit

Permalink
Merge pull request geerlingguy#51 from geerlingguy/highsierra-10.13-a…
Browse files Browse the repository at this point in the history
…nd-docs

Add support for High Sierra 10.13 and update README
  • Loading branch information
geerlingguy authored Aug 15, 2018
2 parents 6ae8b09 + 0aa58ae commit 8276ce8
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 54 deletions.
61 changes: 36 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,57 @@
# macOS VirtualBox VM Instructions

Current macOS version: *Sierra (10.12)*, tested with VirtualBox *5.1.6 r110634*
Current macOS version: *High Sierra (10.13)*, tested with VirtualBox *5.2.16 r123759*

To build a VM running macOS, follow the directions below:

1. Download the installer from Mac App Store (it should be available in the 'Purchases' section if you've acquired it previously). The installer will be placed in your Applications folder. (Should work for Yosemite, El Capitan and Sierra - 10.10-10.12.).
1. Download the installer from Mac App Store (it should be available in the 'Purchases' section if you've acquired it previously). The installer will be placed in your Applications folder. (Should work for Yosemite, El Capitan, Sierra and High Sierra - 10.10-10.13.)
- **Note**: On newer hardware, you might not be able to download older OS releases that Apple doesn't support on the newer hardware (e.g. the 2016 MacBook Pro can only download 10.12 Sierra or later). In this case, you need to use an older Mac to download the older OS.
2. Make the script executable and run it: `chmod +x prepare-iso.sh && ./prepare-iso.sh`.

If the script fails to find the installer you can specify its path as the first parameter. By default, the output is saved as <Yosemite|El Capitan|Sierra>.iso on the Desktop. You can change this using the second parameter.
If the script fails to find the installer you can specify its path as the first parameter. By default, the output is saved as <Yosemite|El Capitan|Sierra|High Sierra>.iso on the Desktop. You can change this using the second parameter.
Example:

./prepare-iso.sh /Applications/Install\ macOS Sierra\ 2.1\ Beta\ 2.app sierra-2.1-b2

3. Open VirtualBox and create a new VM.
4. Set:
- name: your choice
- name: Choose a name
- type: `Mac OS X`
- version: [choose the version corresponding to the installer you're using, e.g. `macOS 10.13 High Sierra (64-bit)`].
5. Follow the rest of the VM creation wizard and either leave the defaults or adjust to your liking. Increase the video memory from the VirtualBox default of 16MB to at least 128MB, otherwise Sierra might not boot correctly, and display performance will be abysmal.
6. In Terminal, run the command `VBoxManage modifyvm "{vmname}" --cpuidset 00000001 000306a9 00020800 80000201 178bfbff` (where `"{vmname}"` is the exact name of the VM set in step 4) so the VM has the right CPU settings for macOS.
7. To prevent choppiness in the VM, go into settings and uncheck the 'Enable Audio' option under 'Audio'.
- version: `Mac OS X (64-bit)`.
5. Follow the rest of the VM creation wizard and either leave the defaults or adjust to your liking.
6. Go into the Settings for the new VM you created and:
1. Under 'Display', increase the Video Memory to at least 128MB, otherwise macOS might not boot correctly, and display performance will be abysmal.
2. Under 'Audio', uncheck 'Enable Audio', otherwise the VM may display 'choppy' performance.
7. In Terminal, run the command `VBoxManage modifyvm VM_NAME --cpuidset 00000001 000306a9 00020800 80000201 178bfbff` (where `VM_NAME` is the exact name of the VM set in step 4) so the VM has the right CPU settings for macOS.
8. Click 'Start' to boot the new VM.
9. Select the iso created in step 2 when VirtualBox asks for it.
10. In the installer, select your preferred language.
11. Go to `Utilities > Disk Utility`. Select the VirtualBox disk and choose `Erase` to format it as a `Mac OS Extended (Journaled)` drive.
11. Open Disk Utility and format the volume:
1. Go to `Utilities > Disk Utility`, select the VirtualBox disk, and choose `Erase` to format it as:
- For macOS < 10.13, choose `Mac OS Extended (Journaled)`
- For macOS 10.13 and later, choose `APFS`.
12. Quit Disk Utility, and then continue with installation as normal.


## Troubleshooting & Improvements

- I've noticed that sometimes I need to go in and explicitly mark the iso as a Live CD in the VM settings in order to get the VM to boot from the image.
- If you try to start your VM and it does not boot up at all, check to make sure you have enough RAM to run your VM.
- Conversely, VirtualBox sometimes does not eject the virtual installer DVD after installation. If your VM boots into the installer again, remove the ISO in `Settings -> Storage`.
- VirtualBox uses the left command key as the "host key" by default. If you want to use it for shortcuts like `command+c` or `command-v` (copy&paste), you need to remap or unset the "Host Key Combination" in `Preferences -> Input -> Virtual Machine`.
- The default Video Memory of 16MB is far below Apple's official requirement of 128MB. Increasing this value may help if you run into problems and is also the most effective performance tuning.
- Depending on your hardware, you may also want to increase RAM and the share of CPU power the VM is allowed to use.
- When the installation is complete, and you have a fresh new macOS VM, you can shut it down and create a snapshot. This way, you can go back to the initial state in the future. I use this technique to test the [`mac-dev-playbook`](https://github.com/geerlingguy/mac-dev-playbook), which I use to set up and configure my own Mac workstation for web and app development.
- I've noticed that sometimes I need to go in and explicitly mark the iso as a Live CD in the VM settings in order to get the VM to boot from the image.
- If you try to start your VM and it does not boot up at all, check to make sure you have enough RAM to run your VM.
- Conversely, VirtualBox sometimes does not eject the virtual installer DVD after installation. If your VM boots into the installer again, remove the ISO in `Settings -> Storage`.
- VirtualBox uses the left command key as the "host key" by default. If you want to use it for shortcuts like `command+c` or `command-v` (copy&paste), you need to remap or unset the "Host Key Combination" in `Preferences -> Input -> Virtual Machine`.
- The default Video Memory of 16MB is far below Apple's official requirement of 128MB. Increasing this value may help if you run into problems and is also the most effective performance tuning.
- Depending on your hardware, you may also want to increase RAM and the share of CPU power the VM is allowed to use.
- When the installation is complete, and you have a fresh new macOS VM, you can shut it down and create a snapshot. This way, you can go back to the initial state in the future. I use this technique to test the [`mac-dev-playbook`](https://github.com/geerlingguy/mac-dev-playbook), which I use to set up and configure my own Mac workstation for web and app development.
- If for High Sierra you can not find the VirtualBox disk created inside the Disk Utility select `View -> Show All Devices` and format the newly visible device ([Source: tinyapps.org](https://tinyapps.org/blog/mac/201710010700_high_sierra_disk_utility.html)).
- If for High Sierra you encounter boot / EFI problems, restart the VM and hit `F12` to get to the VirtualBox boot manager. Select **EFI In-Terminal Shell** and run:

```bash
Shell> fs1:
FS1:\> cd "macOS Install Data"
FS1:\macOS Install Data\> cd "Locked Files"
FS1:\macOS Install Data\Locked Files\> cd "Boot Files"
FS1:\macOS Install Data\Locked Files\Boot Files\> boot.efi
```

## Larger VM Screen Resolution

Expand All @@ -45,22 +60,18 @@ To control the screen size of your macOS VM:
1. Shutdown your VM
2. Run the following VBoxManage command:

VBoxManage setextradata "[VM_NAME]" VBoxInternal2/EfiGopMode N
VBoxManage setextradata VM_NAME VBoxInternal2/EfiGopMode N

Replace `[VM_NAME]` with the name of your Virtual Machine. Replace `N` with one of 0,1,2,3,4,5. These numbers correspond to the screen resolutions 640x480, 800x600, 1024x768, 1280x1024, 1440x900, 1920x1200 screen resolution, respectively.
Replace `VM_NAME` with the name of your Virtual Machine. Replace `N` with one of 0,1,2,3,4,5. These numbers correspond to the screen resolutions 640x480, 800x600, 1024x768, 1280x1024, 1440x900, 1920x1200 screen resolution, respectively.

The video mode can only be changed when the VM is powered off and remains persistent until changed. See more details in [this forum discussion](https://forums.virtualbox.org/viewtopic.php?f=22&t=54030).

## Notes

- Code for this example mostly comes from VirtualBox forums and [this article](http://sqar.blogspot.de/2014/10/installing-yosemite-in-virtualbox.html).
- Subsequently updated to support Yosemite - Sierra based on [this thread](https://forums.virtualbox.org/viewtopic.php?f=22&t=77068&p=358865&hilit=elCapitan+iso#p358865).
- I'm currently looking into using Packer (maybe in tandem with Ansible) to automate the process of building a macOS box for VirtualBox. Since the ISO needs to be generated by the end user, it's a bit more involved (i.e. manual download of the original installer image), but not much worse than Packer for linux distros.
- See also:
- https://github.com/timsutton/osx-vm-templates
- https://github.com/AndrewDryga/vagrant-box-osx-mavericks/blob/master/README.md
- The code for this example originally came from VirtualBox forums and especially [this article](http://sqar.blogspot.de/2014/10/installing-yosemite-in-virtualbox.html).
- Subsequently updated to support Yosemite - Sierra based on [this thread](https://forums.virtualbox.org/viewtopic.php?f=22&t=77068&p=358865&hilit=elCapitan+iso#p358865), and High Sierra and beyond based on the work of a number of contributors (thanks!).
- To install command line tools after macOS is booted, open a terminal window and enter `xcode-select --install` (or just try using `git`, `gcc`, or other tools that would be installed with CLI tools).

## Author

This project was created in 2015 by [Jeff Geerling](http://jeffgeerling.com/).
This project was created in 2015 by [Jeff Geerling](https://www.jeffgeerling.com/).
76 changes: 47 additions & 29 deletions prepare-iso.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/bin/bash

#
# This script will create a bootable ISO image from the installer application for El Capitan (10.11) or the new Sierra (10.12) macOS.
# Restructured a bit, and adapted the 10.11 script from this URL:
# https://forums.virtualbox.org/viewtopic.php?f=22&t=77068&p=358865&hilit=elCapitan+iso#p358865
#
# This script will create a bootable ISO image from the installer application for
# - El Capitan (10.11)
# - Sierra (10.12)
# - High Sierra (10.13)

#
# createISO
Expand All @@ -22,9 +21,6 @@ function createISO()

# echo Debug: installerAppName = ${installerAppName} , isoName = ${isoName}

# ==============================================================
# 10.11 & 10.12: How to make an ISO from the Install app
# ==============================================================
echo
echo Mount the installer image
echo -----------------------------------------------------------
Expand All @@ -37,6 +33,7 @@ function createISO()
echo $ hdiutil attach /Applications/"${installerAppName}"/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
hdiutil attach /Applications/"${installerAppName}"/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
error=$?
installerAppName="/Applications/${installerAppName}"
else
echo Installer Not found!
error=1
Expand All @@ -62,24 +59,41 @@ function createISO()
echo
echo Restore the Base System into the ${isoName} ISO image
echo --------------------------------------------------------------------------
echo $ asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
if [ "${isoName}" == "HighSierra" ] ; then
echo $ asr restore -source "${installerAppName}"/Contents/SharedSupport/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
asr restore -source "${installerAppName}"/Contents/SharedSupport/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
else
echo $ asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
fi

echo
echo Remove Package link and replace with actual files
echo --------------------------------------------------------------------------
echo $ rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
echo $ cp -Rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/
cp -Rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/
if [ "${isoName}" == "HighSierra" ] ; then
echo $ ditto -V /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/
ditto -V /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/
else
echo $ rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
echo $ cp -rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/
cp -rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/
fi

echo
echo Copy macOS ${isoName} installer dependencies
echo --------------------------------------------------------------------------
echo $ cp -Rp /Volumes/install_app/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist
cp -Rp /Volumes/install_app/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist
echo $ cp -Rp /Volumes/install_app/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/BaseSystem.dmg
cp -Rp /Volumes/install_app/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/BaseSystem.dmg
if [ "${isoName}" == "HighSierra" ] ; then
echo $ ditto -V "${installerAppName}"/Contents/SharedSupport/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist
ditto -V "${installerAppName}"/Contents/SharedSupport/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist
echo $ ditto -V "${installerAppName}"/Contents/SharedSupport/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/BaseSystem.dmg
ditto -V "${installerAppName}"/Contents/SharedSupport/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/BaseSystem.dmg
else
echo $ cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist
cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist
echo $ cp -rp /Volumes/install_app/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/BaseSystem.dmg
cp -rp /Volumes/install_app/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/BaseSystem.dmg
fi

echo
echo Unmount the installer image
Expand All @@ -100,7 +114,7 @@ function createISO()
hdiutil resize -size `hdiutil resize -limits /tmp/${isoName}.sparseimage | tail -n 1 | awk '{ print $1 }'`b /tmp/${isoName}.sparseimage

echo
echo Convert the sparse bundle to ISO/CD master
echo Convert the ${isoName} sparse bundle to ISO/CD master
echo --------------------------------------------------------------------------
echo $ hdiutil convert /tmp/${isoName}.sparseimage -format UDTO -o /tmp/${isoName}
hdiutil convert /tmp/${isoName}.sparseimage -format UDTO -o /tmp/${isoName}
Expand Down Expand Up @@ -140,30 +154,34 @@ function installerExists()
# Main script code
#
# Eject installer disk in case it was opened after download from App Store
# added support for multiple disks
for disk in $(hdiutil info | grep /dev/disk | grep partition | cut -f 1); do
hdiutil detach -force ${disk}
done

# See if we can find either the ElCapitan or the Sierra installer.
# See if we can find an eligible installer.
# If successful, then create the iso file from the installer.

installerExists "Install macOS Sierra.app"
installerExists "Install macOS High Sierra.app"
result=$?
if [ ${result} -eq 0 ] ; then
createISO "Install macOS Sierra.app" "Sierra"
createISO "Install macOS High Sierra.app" "HighSierra"
else
installerExists "Install OS X El Capitan.app"
installerExists "Install macOS Sierra.app"
result=$?
if [ ${result} -eq 0 ] ; then
createISO "Install OS X El Capitan.app" "ElCapitan"
createISO "Install macOS Sierra.app" "Sierra"
else
installerExists "Install OS X Yosemite.app"
installerExists "Install OS X El Capitan.app"
result=$?
if [ ${result} -eq 0 ] ; then
createISO "Install OS X Yosemite.app" "Yosemite"
createISO "Install OS X El Capitan.app" "ElCapitan"
else
echo "Could not find installer for Yosemite (10.10), El Capitan (10.11) or Sierra (10.12)."
installerExists "Install OS X Yosemite.app"
result=$?
if [ ${result} -eq 0 ] ; then
createISO "Install OS X Yosemite.app" "Yosemite"
else
echo "Could not find installer for Yosemite (10.10), El Capitan (10.11), Sierra (10.12), or High Sierra (10.13)."
fi
fi
fi
fi

0 comments on commit 8276ce8

Please sign in to comment.