Installing MacOS to VirtualBox

In work you may need to build your application in MacOS environment without Apple Macbook or iMac or other hardware.

I just not found good tutorial in English and make decision make my own. Let’s start!


Dependencies

VirtualBox

Go to https://www.virtualbox.org/wiki/Downloads and download last virtual box package for you OS.

MacOS Sierra ISO

Get it here https://drive.google.com/drive/folders/0Bx7BAMlD-ZOQSTc2NmpDU2g2WDA


Process

Open VirtualBox and start creating new VM for OSX in expert mode(by default).

Name your new machine as “MacOS”.
Choose last version from possible versions. Currently is “Mac OS X 10.11 El Capitan (64-bit)”.
Set memory size to 4096 MB.
Choose “Create a virtual hard disk now”(by default).
Click “Create”

On next step all options are good for our task. Just click “Create”.

Virtual machine created! 🎉

In list of VMs open context menu for “MacOS” VM and choose “Settings”.

On “System/Motherboard” set “Boot order” like on screenshot

On “System/Processor” increase processors count to maximum green value.

On “Display/Screen” increase “Video Memory” to 128 MB

On “Storage” delete “Empty” controller and create “Add SATA Controller”. Add optical drive to new controller. Choose ISO file from step dependencies.

On “Audio” disable “Enable audio” checkbox

On “Network” use default options. Click on “Port forwarding” and add new row.

Close VM settings and open console in host machine and run next commands:

VBoxManage modifyvm “MacOS” — cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage setextradata “MacOS” “VBoxInternal/Devices/efi/0/Config/DmiSystemProduct” “iMac11,3”
VBoxManage setextradata “MacOS” “VBoxInternal/Devices/efi/0/Config/DmiSystemVersion” “1.0”
VBoxManage setextradata “MacOS” “VBoxInternal/Devices/efi/0/Config/DmiBoardProduct” “Iloveapple”
VBoxManage setextradata “MacOS” “VBoxInternal/Devices/smc/0/Config/DeviceKey” “ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc”
VBoxManage setextradata “MacOS” “VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC” 1
VBoxManage setextradata “MacOS” VBoxInternal2/EfiGopMode 4

Start VM and start to install MacOS

When installation request for disk start “Disk Utility”

Erase “VBOX HARDDISK”

And choose it

After installation enable “Remote Login” in MacOS virtual machine.

Open “System Preferences/Sharing” and enable “Remote Login” checkbox. Set “Allow access for” for “All users”. Check address below “Remote Login: On”. It is look like “ssh user@10.0.2.15”. Check this IP with “Guest IP” in “Settings/Network/Port forwarding” for virtual machine. They must be equal.

Finish!

Now you can to connect via ssh to your local port.

ssh user@127.0.0.1 -p2222