NOTE
Install OSX 10.13
![10.11 10.11](/uploads/1/2/6/2/126287409/834443604.jpg)
1) Create a VM in virtualbox named something, type Mac OS X, version Mac OS X 10.7 Lion (64 bit). 2) Before booting the VM, switch to Terminal and change the cpuid of the guest by running VBoxManage modifyvm something --cpuidset 1 000206a7 02100800 1fbae3bf bfebfbff. Official way to obtain an OS X ISO file. Select Images > Convert and point it to your.dmg file. I own a MacBookPro, I'll literally destroy it, if I can retain rights to use exactly one copy of Mac OS X on my PC running in VirtualBox. That way, Apple makes their money on their hardware, and I get to use it on one, and only one, PC of my.
: The instructions to create an ISO from any OSX Install application are covered in another article.Install OSX 10.13
- Create a new VM with the 10.13 template. Accept the defaults, with the exception of RAM (at least 3 GB), number of vCPUs (at least 2) and amount of HD (according to your needs, no less than 10 GB). Also make sure that USB3 controller is selected under the Ports » USB. Choose the newly created ISO as your boot medium.
NOTE: Do NOT designate your virtual HD as an 'SSD'. The installation WILL fail if you do that, because the OSX installer will convert the filesystem to APFS, something that the VirtualBox EFI can not handle. - Start the VM. It may seem that the installation stalls but don't shut the VM, be patient. Specifically, right before you switch to the graphics with the Apple logo and the progress bar, you'll get stuck at the point where the OSX ≥ 10.12.4 gets stuck:
- After selecting the language, open 'Disk Utility'. For reasons that only Apple engineers understand, you will *not* see your hard drive! Instead you'll see a bunch of partitions that are of no interest to you whatsoever (see NOTE below). On the top-left side, click on the 'View' drop-down and select 'Show All Devices'. Now you'll see your 'VBOX HARDDISK Medium'. Select it and choose 'Erase' from the toolbar. Leave the defaults (HFS+J/GUID), except maybe the name, choose anything you like. Quit 'Disk Utility' once done.
NOTE: This 'glitch' has been fixed with 10.13.2. Now the hard disk shows properly when Disk Utility is opened. - Select 'Install macOS'. Continue and agree to the license. This will start a phase where the actual installer is copied to the Recovery Partition of the hard disk that you selected. That part is rather quick, lasting less than a couple of minutes on an SSD drive. After that your VM reboots. But, you won't re-boot into the OSX installation phase, you'll restart the whole installation again from scratch! Houston, we have a problem!!! If you're observant, you'll notice a quick message coming up, right before the VM boots again from the ISO to restart the whole installation process:
- Apple (another wise move) has modified the way that it reads/treats the different partitions in the EFI, something that currently VirtualBox cannot handle (as of 5.2.2). But, there is a solution. Once you find yourself up and running, right after the language selection step, shut down the VM and eject the 10.13 ISO that you booted from. Then boot the VM again. You get dropped in the EFI Shell.
- You need to keep resetting the VM (HostKey+R) and press any key until you get into the EFI menu screen. If you don't succeed, and you end up in the EFI shell, enter 'exit'. That will you get to the EFI menu, shown below:
- Select the 'Boot Maintenance Manager' option, then 'Boot from File'. Now, you should have two options. The first one is your normal Boot partition, but this is not yet working, because you haven't yet installed 10.13. This is where the VM should be booting up from normally, and this is why it fails to boot. The second partition however is your Recovery partition. This is the one you should boot from to do the installation. This could be also used to do a re-installation of 10.13, just like on a real system, should the need arise.
- BootFromFile.png (48.02 KiB) Viewed 58207 times
- Choose the second option, then '<macOS Install Data>', then 'Locked Files', then 'Boot Files', and finally 'boot.efi' and let the games begin!
- That second part of the installation is where 10.13 actually gets installed. This is going to take substantially more time, about 20-30 min with the VM consuming every available CPU cycle. The VM will reboot a couple of times but you should be all set.
![10.11 10.11](/uploads/1/2/6/2/126287409/834443604.jpg)
Current macOS version: High Sierra (10.13), tested with VirtualBox 5.2.16 r123759
To build a VM running macOS, follow the directions below:
- 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, Mojave - 10.10-10.14.)
- 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.
- 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|High Sierra|Mojave>.iso on the Desktop. You can change this using the second parameter.Example: - Open VirtualBox and create a new VM.
- Set:
- name: Choose a name
- type:
Mac OS X
- version:
Mac OS X (64-bit)
.
- Follow the rest of the VM creation wizard and either leave the defaults or adjust to your liking.
- 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.
- In Terminal, run the command
VBoxManage modifyvm VM_NAME --cpuidset 00000001 000306a9 00020800 80000201 178bfbff
(whereVM_NAME
is the exact name of the VM set in step 4) so the VM has the right CPU settings for macOS. - Click 'Start' to boot the new VM.
- Select the iso created in step 2 when VirtualBox asks for it.
- In the installer, select your preferred language.
- Open Disk Utility and format the volume:1. Go to
Utilities > Disk Utility
, select the VirtualBox disk, and chooseErase
to format it as:- For macOS < 10.13, choose
Mac OS Extended (Journaled)
- For macOS 10.13 and later, choose
APFS
.
- For macOS < 10.13, choose
- 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
orcommand-v
(copy&paste), you need to remap or unset the 'Host Key Combination' inPreferences -> 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
, 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). - 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: - If keyboard and mouse do not work inside the VM:
- Ensure the VirtualBox Extension Pack is installed.
- In the VM settings, under
Ports > USB
, selectUSB 3.0 (xHCI) Control
.
Larger VM Screen Resolution
To control the screen size of your macOS VM:
- Shutdown your VM
- Run the following VBoxManage command:
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.
Notes
- The code for this example originally came from VirtualBox forums and especially this article.
- Subsequently updated to support Yosemite - Sierra based on this thread, 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 usinggit
,gcc
, or other tools that would be installed with CLI tools).
Author
This project was created in 2015 by Jeff Geerling.