Oct 25, 2018 - During a recent pentest, I needed to throw together a macOS virtual. In order to get a fully working High Sierra install within VirtualBox 5.
Update: Written for OSX El Capitan. Works for macOS Sierra as well. While VirtualBox is a great product easy to use to create Virtual Machines and configure in few minutes, trying to create a Virtual Machine with a OSX system could be very tricky. With this guide I will explain a procedure you can follow if you want to install a Mac OS X system on VirtualBox, running on Max OS X as well.
I wanted to describe this because the information available are often confused, missing and too many times they require the download of extra software or installer (generally to avoid the very common issue where the UEFI Interactive Shell is displayed or the text “Fatal: no bootable medium found! System Halted”, that you can see if you selected EFI support for your Virtual Machine). If you find this useful or interesting please share and comment for more to come! Time to start! Table of Contents.
Create ISO from installer The very first thing to do is to download the OS X Installer. I wrote a dedicated post for this and you can find it here: Time to do some magic! As it stand the installer will not work on the Virtual Machine (and you will experience the error I mentioned at the start of the article). What we’ll need to do is manipulate the installer disk in order to make it ready for our Virtual Machine to understand. I will put the whole list of commands at the end of this article, but I will explain every line to make it clear what’s going on. We’ll make heavy use of the “ hdiutil” tool.
It is a command used to manipulate disk images and you can find detailed about this command here: 1. Attach the installer image First thing we need to do is attaching the image of the installer (that we downloaded) as a device. Effectively simulating a device (the installation disk in this case) attached to our mac. We achieve this using the “ hdiutil” command: “ attach“. Hdiutil attach '/Applications/Install OS X El Capitan.app/Contents/SharedSupport/InstallESD.dmg' - nobrowse - noverify - mountpoint / Volumes / esd 2. Create new image We want now to create a new image.
For this we’ll use the “ hdiutil” command: “ create”. We give the image an output file: “ -o Installer.cdr“.
I’ll set the size to 7.5GB (you can increase it if you’ll need to): “ -size 7.5g“. Then we specify the layout of the image.
We’ll use “ SPUD“, that from the documentation: “SPUD causes a DDM and an Apple Partition Scheme partition map with a single entry to be written.”. For the filesystem (of the image) we’ll use the standard HFS+J: “ -fs HFS+J“. Hdiutil attach OSXInstaller. Dmg - nobrowse - noverify - mountpoint / Volumes / iso 4. Copy the System Installer to the new disk image The real installer is inside the disk image “BaseSystem.dmg” contained in “InstallESD.dmg” (that we attached to the volume “ /Volumes/esd/“).
What we need to do is copy the content of this disk image (so the content of “BaseSystem.dmg”) into the root of our new installer disk (that we attached to “ /Volumes/iso/“). For this we use now the command “ asr” that copies disk images into volumes and we just tell it to restore the image from “ /Volumes/esd/BaseSystem.dmg” into “ /Volumes/iso“. The other options are to avoid verification and to skip the prompting of confirmation to continue (essentially to avoid to answer “yes” to the erase disk confirmation). Note: the “ -erase” option is now mandatory (or “asr” will refuse to run with the error: “File copy is not supported anymore.
Use the –erase flag.”). This is the full command. Cp -rp /Volumes/esd/Packages /Volumes/OS X Base System/System/Installation At the end of this the “ Pakages” folder should be back in place (but for real this time, not anymore as a link) in the disk we are manually creating (the folder will be therefore in “ /Volumes/OS X Base System/System/Installation/Packages“). Copy the remaining missing files If you look again in the original InstallESD disk, you can see other files in the root: Ignore the two AppleDiagnostic files (we don’t care about these). We need to copy the two BaseSystem files in the root of our disk.
Mv OSXInstaller. Cdr OSXInstaller. Iso Create the Virtual Machine Open now VirtualBox (you can download it there: ““). I’m using version 5.0.20. Creation Proceed creating a new Virtual Machine. You can do this by clicking the blue icon (“new”) at the top: Give a name. If you name it something like “OSX” VirtualBox will automatically select the type of Virtual Machine you want to create (“Mac OSX”): Click “Continue” and select then the memory size in the next screen.
I pick 4096MB: Create a virtual hard disk: Select the default VDI (VirtualBox Disk Image) disk type: Go ahead and pick (if you want) Dynamically allocated: Select then the file location (the name really) and size (I will create a 40GB HD): At this point the creation procedure will complete and you should be able to locate your newly created Virtual Machine: 2. Configuration Select it and click on the “Settings” button: Select the “Display” section (subsection “Screen”) and fix the amount of Video Memory if it is something like 1MB or 8MB. Move it to the max 128MB: Enter then the “Storage” section and select the “Empty” disk.
Click the CD icon on the right and pick the “Choose Virtual Optical Disk File” from the menu that will pop-up: Locate and select the iso we created in the previous chapter (“ OSXInstaller.iso“): At this point press “OK” and we are ready! Install OSX on the VM We can now start the real OSX installation procedure! Start the VM Time to run our Virtual Machine for the first time!
Click on the green “Start” arrow: It should now start and you should see the console printing out a lot of data wait patiently: and more Finally start the installation procedure selecting your language: Click “Continue: on the next screen: 2. Create an HDD partition To install the system we need to create an Hard Disk first. You can now run again the Virtual Machine and this time the second part of the OSX installation procedure should kick in: Go ahead and complete the installation.
This video shows this procedure: embedytAt the end you should finally be able to boot into your brand new freshly installed OSX Virtual Machine!:) That’s all! If you enjoyed this article, found it interesting or just learned something new (or simply liked it) please share it, comment or feel free to if you think I deserved it or you simply want to show your appreciation:). In any case thanks for passing by and until next time! This is an outstanding resource. I really like how you were able to present the information so that it is very useful for people with a wide range of technical knowledge. Novices can just follow step-by-step and likely get to a successful conclusion.
Those with more technical knowledge of OS X can skim through and find the key bits of information they are missing to accomplish the task. The curious (of all types) can benefit from the concise explanations of why these commands and options are being employed. (I’m thinking specifically of the “Create ISO from installer” section.) Needless to say, it worked beautifully for me. The only slight snag I ran into was after running the OS X install process, the VM didn’t just shut down, it restarted — without giving me a chance to “remove” the installation iso from the virtual optical drive as you describe in the next step. During the restart, my VM appeared to get stuck and I thought maybe it was trying to boot from the installer iso again. I just powered down (closed) the VM, removed the iso in the settings as you describe, and started the VM again.
Thank you for putting in the time and effort to make this guide. Are you saying that when you start the VM, it reboots itself over and over, repeatedly? If so, then I guess the “command screen” you mentioned is the “verbose” text output of the OS X booting process, because VirtualBox always adds the “-v” boot argument. I’ve run a few different versions of OS X and VirtualBox on two machines, but haven’t seen a boot loop like that. If you could look at the last few lines of the text that is displayed on the screen during boot maybe it would help narrow down the cause. (Or, maybe not, because the last message probably tells you the last step that did complete successfully, while the real problem might be more related to the what the NEXT message would have said — but never appears!) — Brian H. Hi Riccardo — I’ve come back to this excellent guide to do another install (reason given later).
In the spirit of appreciation I will point out two (very minor) corrections or clarifications for any readers: 1) In “Create ISO From Installer,” section 7, it says “Ignore the BaseSystem.chunklist file and the two AppleDiagnostic files (we don’t care about these).” But the command lines shown in the next box include “cp -rp /Volumes/esd/BaseSystem.chunklist /Volumes/OS X Base System/” which seems to contradict the statement to ignore that file. I did copy that file (as listed in the command box) and it worked fine, but I don’t know whether that file is necessary or not. 2) At the end of the process the file “OSXInstaller.cdr.dmg” is left over, but not very useful. I believe it may be deleted anytime after the “hdiutil convert” command. I used your instructions with success installing macOS 10.12.2 Sierra as the guest OS in a VirtualBox VM.
My host machine is a late 2015 iMac and is running 10.11.6 El Capitan. Currently my VirtualBox is version 5.1.12, the latest right now. I installed Sierra recently because I was unable to update my working El Capitan VM with a recent security update from Apple without getting strange errors afterwards (code signing errors, Finder crashing, etc.).
Previous updates had worked fine, though. Sierra is now running well, but once again during installation I had a little problem (as I mentioned in comments above) that others might encounter: as part of the normal OS X install procedure, the VM was automatically restarted, and it seemed to get stuck (hang, freeze) during the restart, with a black console screen and a few lines of text (I think). I waited over 30 minutes but it never proceeded. So I closed the VirtualBox VM window (this does an abrupt “power off” on the VM), and then started the VM again.
This time it booted OK and went through the normal completion of the OS X installation and all appears fine. Thanks again, Riccardo, and good luck to everyone! Thanks a lot Riccardo for this posting, it really worked for me installing Mac OS Sierra VirtualBox on a MacBook Pro. However there seems to be a shortcoming, when switching the OSX VirtualBox to Full Screen Mode (Host+F) the window doesn’t expand all the way to the host display. I know that Virtual Box currently doesn’t support additions for MAC. Although there is a pkg file in the ISO for Additions this doesn’t seem to work, do you know any way to work around this? Thanks again for your posting and any hint would be appreciated Alex.
![For For](/uploads/1/2/5/5/125568290/663930876.jpg)
Hi Alex – I’m not associated with the web page author but have some info that may help you. For a guest OS X (MacOS) in Virtualbox, you must choose one of only six possible screen resolutions that can be set in the EFI (the firmware) for the virtual machine. This is done by a Terminal command like ‘VBoxManage setextradata “my-vm-name” VBoxInternal2/EfiGopMode N where N can be one of 0,1,2,3,4,5 referring to the 640×480, 800×600, 1024×768, 1280×1024, 1440×900, 1920×1200 screen resolution respectively. Perhaps none of the choices are perfect for your setup — you just have to pick the one that is “best”. If they ever create guest additions for MacOS then there could be other choices. But for now, these are the only ones that work.
Here is the section of the manual that describes this better. I found my mistake! In this specific case you don’t really need to create a physical bootable USB. The main thing you need in order to install Sierra on a VM is only the installer app. So, if you were following the previous article, you can follow it until you have the app downloaded (that happens at the very start, before the section “Prepare the USB”).
Once you have it, you can continue with this article from “Time to do some magic!”. In it, in fact, all the operations are performed on this file (the downloaded one, that I have in the Applications folder: “/Applications/Install OS X El Capitan.app”) that contains the image of the installer disk (“/Applications/Install OS X El Capitan.app/Contents/SharedSupport/InstallESD.dmg“) This file (on your mac) is the one we mount in place, simulating an inserted media (in the section “Attach the installer image”). Then everything else continues from there:). Thanks for the comment and let me know if this helps:). Many thanks for these clear and informative instructions – I now have a freshly installed 10.12.3 guest running on my 2009 Mac Pro/Mac OS 10.10.5 host:) I had previously built a guest from installing 10.6 server and then disk copying an image of an OS install to another virtual disk – I process that I have never managed to fully replicate!
![What mac os is needed for virtualbox download What mac os is needed for virtualbox download](http://cdn.osxdaily.com/wp-content/uploads/2015/03/windows-10-on-mac-screenshot.jpg)
I used 10.12.3 in the end as I ran into the same issue as per Jose Bernal’s 2017-08-04 post when trying 10.12.6 – it seems that 10.12.6 doesn’t like vBox’s EFI vendor. Not a huge problem as I am close enough to where I need to be with my VM.
In step 6 of the ISO creation process, the copy command put the files into the directory /Volumes/OS X Base System/System/Installation; the accompanying image shows the files in a Packages/ sub-directory, which reflects the original directory structure – I opted to mimic this, which worked fine when I came to install from the ISO. Was very helpful to get the ball rolling and create a proper bootable image, but after I had to deal with the following set of issues, which may be of use to someone else: 1.
When trying to setup the VM on non-apple hardware, you’re likely to face the “DSMOS has arrived” (aka “Don’t steal Mac OS”) message, where boot doesn’t go past that point. Considering that I was installing the VM on my ASUSTOR NAS with headless virtualbox, that added more complexity into the mix. If you’re in similar circumstances, then you would need to 1.1 Shutdown the VM and SSH into your remote machine, e.g. Thank you Riccardo for taking the time to make this tutorial. Unfortunately I have followed the steps to the letter (several times) with no luck whatsoever. I am on a new iMac Pro, High Sierra 10.13.3, VirtualBox 5.2.8.
I’ve checked the disk image and it looks good, but the new El Cap VM will not boot from it. The error I am getting is Guru Meditation.
Below is the text along with a paste of my complete log. Any help is much appreciated. A critical error has occurred while running the virtual machine and the machine execution has been stopped.
For help, please see the Community section on or your support contract.
Download pre-installed VirtualBox image from following link. Mirror 1: Mirror 2: For mirror 2, use HjSplit to join the files back. It’s about 5GB. HjSplit is also in Google Drive folder. Extract macOS 10.12 Sierra by TechReviews.rar file to a folder, you’ll get a list of these files 3. In VirtualBox, create a new machine with following settings 4. For Hard drive, browse to macOS 10.12 Sierra by TechReviews.rar file which can be found in extract folder before.
Click Create. Right click on the new machine and select Settings. Be sure that Floppy Disk is disabled. Set number of processors to the max of real processors you have, it’ll speed up the installation. I have a dual core so I set the number of processors to 2. In Display settings, set Video Memory to max 128MB. Start your cmd and execute following code.