I’m trying to install macOS Sierra on VirtualBox, but can’t seem to make it work. For reference, here are the steps I took.
- Downloaded the Install macOS Sierra app from the App Store.
- Used the inbuilt media creation executable,
CreateInstallMedia
on a disk image. - Created a new VM with the default settings for an OS X El Capitan, plus 128 VRAM.
- Since VirtualBox refused to accept the DMG, I tried splicing out the InstallESD.
- VirtualBox now accepted it, but wouldn’t boot. I tried to boot through rEFInd, but still no luck.
- I tried to patch it both ways (base system and ESD) with iesd. No luck.
- When booting to GParted LiveCD, it flat-out refused to discover any of the installer CDs.
How can I patch the installer to work with VirtualBox? I don’t want to use pre-patched versions of either the installer or an existing installation, as though to avoid piracy.
Best Answer
Installing macOS as a VM in VirtualBox
These instructions will guide you through the process of creating and using bootable media to install macOS in a VirtualBox VM.
Pre-Requisites
We are going to use the
createinstallmedia
utility included with the macOS Install App to create a USB image. However, there's nothing that says it must be a physical USB device and not a disk image instead. For this we are going to use VB's ability to access a "raw" drive through a VMDK which will act as a pass-through device that VB can recognize and mount.In the steps below, assume the working directory is the user's home (
~/
).Step 1: Create the Installation Media
Using
hdiutil
create a sparse (expanding) disk image with a size of 6GBNext, mount the image
You will get a message that looks similar to the one below. Pay attention to the disk identifier as you will need it in Step 2. In my environment, mine was
disk7
your's will likely be different.Finally, use
createinstallmedia
from the macOS Installer to create the installation image:Allow it to finish. When it's done it will automount the new Volume and you should see it on your Desktop.
The newly created image will need to be unmounted for the next step, so go ahead an unmount the disk.
Step 2: Create the VMDK
To do this, we are going to use VirtualBox's "raw hard disk access" to create a pass through to the newly created drive image.
The syntax of the command is as follows:
So, for our purposes, the command would be (note the escaped spaces)
The VMDK will be a very small file that simply points to disk you created in Step 1. Now you can attach the VMDK to your VM and boot from it.
Add the VMDK to your VM and Boot
Before you can add the newly created VMDK to your VM, you need to take ownership of it. Since it was created using
sudo
, root has ownership and rights. Be sure to replace "joeuser" with your username in the command example below:Using the VirtualBox GUI, select the desired VM, click Settings, click Storage, click Add Hard Disk button, select Choose existing drive, and then select the VMDK file you just created.
Boot your VM. VirtualBox will automatically find the bootable volume and begin the installation process.