Six years with Mac OS X as my primary operating system (OS) has included three hardware upgrades and a couple fresh installs. The complete OS and application rebuilds were not necessitated by any particular problems. It is mostly a psychological carry over from two decades of painful Microsoft Windows upgrades. Something just feels right about a complete reinstall. Recently I've been testing automated ways of installing applications and customizing the configuration of both apps and the OS. Having a virtual machine (VM) to test with makes the process go faster, so I set out to build a macOS VM. The steps below resulted in a working macOS VM on my MacBook Pro (MBP).
A guide to installing a macOS virtual machine on a macOS host.
Apple License Agreement Compliance
Before we get started I must point out that I'm not violating the Licensing Agreement nor am I suggesting anyone do so. Per Apple's Software License Agreement for OS X Yosemite you are granted a limited, non-transferable, non-exclusive license:
(iii) to install, use and run up to two (2) additional copies or instances of the Apple Software within virtual operating system environments on each Mac Computer you own or control that is
already running the Apple Software, for purposes of: (a) software development; (b) testing during
software development; (c) using OS X Server; or (d) personal, non-commercial use.
This guide assumes you have VirtualBox 5.x installed on your macOS host machine.
Currently, I have not had any luck getting macOS El Capitan (10.11.x) to boot in a VirtualBox VM. Most likely this is due to Apple's change from an MBR (master boot record) base system to GPT (GUID partition table). As a result I had to download Install OS X Yosemite from the Apple App Store to my MBP.
Install iESD Ruby Gem
The iESD ruby gem enables you to modify extensions, kextcache, and packages in macOS InstallESD disk image used by Mac OS X installer. It will be used to convert the Yosemite installer into a disk image format that can be used by VirtualBox.
The first step is to verify that you are running Ruby version 1.9.2 or later. Run the following command and verify the version:
Next install the iESD ruby gem using the command below:
gem install iesd
Create OS X Yosemite Bootable Image
Since the installer included with the Install OS X Yosemite app is not bootable we need to use iESD to create a bootable disk image using the command below:
iesd -i /Applications/Install\ OS\ X\ Yosemite.app -o Yosemite.dmg -t BaseSystem
Install OS X in VirtualBox VM
Create VirtualBox VM
Follow these steps to create a new VirtualBox VM that we will install Mac OS X into:
- Start the VirtualBox GUI application.
- From the Machine menu select New.
- Type macOS into the Name field, select
Mac OS Xfor the Type, select
Mac OS X 10.10 Yosemite (64-bit)for the Version, and click the Continue button.
- The Memory Size should be at least
2048 MB. Click Continue.
Create a virtual hard disk nowand click Create.
VDIand click Continue.
Dynamically allocatedand click Continue.
- Leave the File location as the default
macOSvalue, change the size to
40.00 GB, and click Create.
Configure VirtualBox VM
Now that the VM has been created we'll need to modify a few configuration settings before booting the first time.
- While still in VirtualBox with the newly created macOS VM selected, click the Settings button.
- Select the Storage tab.
- Under the Storage Tree section select the Empty optical drive.
- Click the small CD-ROM image in the Attributes area to the right of the Optical Drive label, and select Virtual Optical Disk File....
- Select the
Yosemite.dmgbootable image file you created earlier and click Open.
- Click OK to close the VM Settings window.
Boot VM and Install OS X Yosemite
It will take anywhere from 15-30 minutes to complete the steps below, including an automated reboot, at which point you should have a running Yosemite VM.
- While still in VirtualBox with the newly created macOS VM selected, click the Start button.
- It may take 1 to 2 minutes to finish booting from the disk image mounted to the optical drive but eventually you will be presented with the Welcome screen.
- Select your preferred language (Use English for the main language in my case) and click the arrow button to continue.
- Before continuing on the next screen we need to format the VirtualBox hard drive created for this VM following these steps
- At the top of the window select Utilities > Disk Utility.
- Select what should be the only drive listed (
42.95GB VBOX HARDDI...).
- Select the Erase tab.
- Ensure the Format is set to
Mac OS Extended (Journaled).
- Set the Name to
- Click the Erase button and then Erase again to begin the process.
- After less than 30 seconds it should be done.
- In the top, left select Disk Utility > Quit Disk Utility.
- Back on the OS X Installer window click the Continue button.
- Click Continue and then Agree if you accept the terms or Cancel if you do not.
- Select the recently formatted
Macintosh HDdrive and Continue.
Initial OS X Setup
After the installation process completes you will be presented with the steps to setup Mac OS X for the first time. I've run into issues with system hang by trying to complete the full setup process so instead I skip some sections as detailed in these steps:
- On the Welcome screen select your country and click Continue.
- Choose a keyboard layout and click Continue.
Don't transfer any information nowand click Continue.
Don't sign in, click Continue, and then Skip to confirm.
- If you accept click Agree twice or go Back if you do not.
- Complete the information to create an initial Administrator account and click Continue.
- Select the settings you prefer on the Diagnostics & Usage window and click Continue.
With any luck setup will complete and you'll be presented with the Yosemite wallpaper and a running system.