Current Mac OS X version: Yosemite
To build a VM running Mac OS X, follow the directions below:
- Download the Yosemite 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.
- Run the included
prepare-iso.sh
script (make it executable first, withchmod 755
, then run./prepare-iso.sh
from the folder containing the script). A new Yosemite installer iso will eventually be saved to the Desktop. - Open VirtualBox and create a new VM.
- Set name, type, and version (set to Mavericks for 'Version').
- Follow the rest of the VM creation wizard and either leave the defaults or adjust to your liking.
- In Terminal, run the command
VBoxManage modifyvm "osx-yosemite" --cpuidset 00000001 000306a9 00020800 80000201 178bfbff
(where "Mac OS X" is the exact name of the OS X VM set in step 4) so the VM has the right CPU settings for Yosemite. - To prevent choppiness in the VM, go into settings and uncheck the 'Enable Audio' option under 'Audio'.
- Click 'Start' to boot the new VM.
- Select the iso created in step 2 when VirtualBox asks for it.
- Once the Yosemite installer appears, instead of clicking 'Continue', first go to Utilities > Disk Utility and partition/format the VirtualBox disk as a "Mac OS X Extended (Journaled)" drive.
- Quit Disk Utility, and then continue with installation as normal.
When the installation is complete, and you have a fresh new Mac OS X VM, you can shut it down and create a snapshot so you can go back to the initial state in the future. I use this technique to test the mac-dev-playbook
, which I use to set up and configure my own Mac workstation for web and app development.
- Code for this example mostly comes from VirtualBox forums and this article.
- I'm currently looking into using Packer (maybe in tandem with Ansible) to automate the process of building an OS X 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.
- To install command line tools after OS X is booted, open a terminal window and enter
xcode-select --install
(or just try usinggit
,gcc
, or other tools that would be installed with CLI tools).
This project was created in 2015 by Jeff Geerling.