Skip to content

Instantly share code, notes, and snippets.

@arobb
Last active November 24, 2020 13:15
Show Gist options
  • Save arobb/447a962af4f07ef81e79987d686275e5 to your computer and use it in GitHub Desktop.
Save arobb/447a962af4f07ef81e79987d686275e5 to your computer and use it in GitHub Desktop.
Install macOS Sierra in VirtualBox on macOS host

Step 1 (Creating a bootable macOS Sierra ISO for VirtualBox):

  1. hdiutil attach /Applications/Install\ macOS\ Sierra\ Public\ Beta.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
  2. hdiutil create -o /tmp/Sierra.cdr -size 7316m -layout SPUD -fs HFS+J
  3. hdiutil attach /tmp/Sierra.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/install_build
  4. asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
  5. rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
  6. cp -rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/
  7. cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist
  8. cp -rp /Volumes/install_app/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/BaseSystem.dmg
  9. hdiutil detach /Volumes/install_app
  10. hdiutil detach /Volumes/OS\ X\ Base\ System/
  11. hdiutil convert /tmp/Sierra.cdr.dmg -format UDTO -o /tmp/Sierra.iso
  12. mv /tmp/Sierra.iso.cdr ~/Desktop/Sierra.iso

Step 2 (Installing in VirtualBox)

This is pretty straightforward.

  1. Create a new El Capitan (there is no option for Sierra at the moment) machine. Leave everything at default
  2. Boot the virtual machine from the Sierra.iso you created, which you'll find on your desktop. I had to mash F12 while the machine was starting up and then choose 'EFI CD/DVD' in the boot manager. YMMV.
  3. The install process should be familiar to you. If not, you probably shouldn't be playing with a beta OS ;)
  4. Grab a coffee, the 15 minute estimation the installer gives you is a complete work of fiction. My install took over an hour.
  5. Once installed, reboot and complete the new user process. Skip the AppleID login bit, it'll fail on a VirtualBox.
  6. Shut down the virtual machine and quit VirtualBox.
@TeodorKolev
Copy link

TeodorKolev commented Feb 7, 2017

I have done steps from 1 to 12 and I get: Disk image is corrupted

@christianbauer
Copy link

If you get a black screen when starting the VM, change the Chipset to PIIX3. In the Installer, open the Disk Utility and Erase the virtual disk before installing.

@blimmer
Copy link

blimmer commented Apr 23, 2017

I followed these instructions and I get stuck at this screen:

gIOScreenLockState 3, hs 0, bs 0, now 0, sm 0x0

anyone have ideas?

@kyeb
Copy link

kyeb commented Apr 25, 2017

@blimmer
Same issue here. Any solution for you yet?

@dbodyas
Copy link

dbodyas commented May 1, 2017

@adespoton
Copy link

Having the same issue guys, but I also tried a different image creation technique and a few other settings.

Instead of this script, I just created an 8GB RW DMG, mounted it, and used sudo Install\ macOS\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/Install\ macOS\ Sierra/ --applicationpath /Applications/Install\ macOS\ Sierra.app

Then I unmounted the disk, and used VBoxManage convertdd Install-10.12.4.dmg Install10.12.3.vdi to create a vdi from it. Added that to my VM and...

...exact same results as this method.

To avoid the black screen, I found I had to increase video mem from 16 to 112 or more. But it still stalls out at the same point. The log provides no useful info.

@McManoli
Copy link

Hi there,

The problem I guess is in macOS Sierra installer 10.12.4

I used the above technique with previous version of installer 10.12.3 and works with no problems. Then you can just download and install combo update for latest one, which is 10.12.5 these days and thats it.

@si294r
Copy link

si294r commented Jun 7, 2017

Hi @mcmanole,

Where i can get macOS Sierra installer 10.12.3 ?

@hist0gram
Copy link

trying to make a iso for the new 10.13 beta but get stuck at the step:

asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase

get the error:

Could not recognize "/Volumes/install_app/BaseSystem.dmg" as an image file
done
Could not retrieve scan information - Invalid argument

it seems that the install ESD does not include a BaseSystem.dmg anymore ... from what I can see it only includes the following:

Packages:
Core.pkg
EmbeddedOSFirmware.pkg
FirmwareUpdate.pkg
OSInstall.mpkg

not sure where to go from here but would be great to get a high Sierra version working on a VM for some testing.

thanks!

@mabam
Copy link

mabam commented Jul 3, 2017

The following worked for me:

Create the ISO for VirtualBox as described here (luckily I already downloaded Sierra in January, so I have version 10.12.2 and don't run into problems as mentioned by McManoli).

Then perform step 3 and 4 from this guide:
http://www.wikigain.com/install-macos-sierra-10-12-virtualbox/ (don't use the downloads provided there).
Except that in step 3, you create a blank image i.s.o. using an existing one. And in step 4, add the ISO created above as optical medium and change the MAC address of the network adapter to a random one of the addresses found here: http://hwaddress.com/company/apple-inc .

The following lines are based on step 5 of above mentioned guide:

cd /Applications/VirtualBox.app/Contents/MacOS/
VBoxManage modifyvm "macOS Sierra" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage setextradata "macOS Sierra" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata "macOS Sierra" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "macOS Sierra" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "BOARD-PRODUCT"
VBoxManage setextradata "macOS Sierra" "VBoxInternal/Devices/efi/0/Config/DmiSystemSerial" "SERIAL"
VBoxManage setextradata "macOS Sierra" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "macOS Sierra" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1

Substitute "macOS Sierra" by your VM name. "BOARD-PRODUCT" and "SERIAL" have to be substituted by values obtained by Chameleon Wizard. You could use a different "System Product" than "iMac11,3". See http://www.insanelymac.com/forum/topic/292170-how-to-spoof-real-mac-in-vmware/ on how to obtain the correct information from Chameleon Wizard (ignore the rest of the guide as it is not for VirtualBox).

(See https://forums.virtualbox.org/viewtopic.php?f=8&t=61825&hilit=DmiSystemSerial under "modifications" on how to change the resolution.)

Enter your version of the above lines in Terminal one by one.

Start the VM and install Sierra.
I have added 3D-acceleration afterwards.

You can even log in with your Apple ID and also authorize iTunes. My host system is too old to backup or update my iPhone, so I do that using this Sierra VM.

If you have already installed Sierra as a VirtualBox VM, add the lines above (make sure you don't create duplicates) and enter into Terminal:
sudo rm /Library/Preferences/com.apple.apsd.plist
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.apsd.plist
(Taken from https://apple.stackexchange.com/questions/208292/cant-login-in-mac-app-store-or-icloud-login-loading-forever )
Restart the VM and you should be able to use your AppleID.

NOTES:
• During startup Sierra reports no valid driver for the USB 3 interface. I had trouble updating my iPhone when using USB 3. So I set it back to USB 2.
This one is a bit specific:
• When updating iOS you sometimes have to reconnect the iPhone manually via the menu a few times. If you have iTunes installed on the host as well, make sure to delete the iTunesHelper.app from the login items of the host first or you go crazy.

@soomonsoon
Copy link

I'm new, so apologies if this is obvious or already asked in a different way. I'm getting errors about legacy APIs, shown in the attached image. I have no idea how to fix that or what the root of the problem is. Does anyone know?

screen shot 2017-08-15 at 11 08 09 am

@ron23
Copy link

ron23 commented Aug 29, 2017

same issue ^^^.
Did you found a solution?

@aeekayy
Copy link

aeekayy commented Aug 29, 2017

@soomonsoon @ron23 I'm seeing the same issue. Any ideas on what's up?

@lpbas
Copy link

lpbas commented Sep 1, 2017

I'm seeing the same issue as you guys (latests Sierra installer from the AppStore). If anyone has a solution please let us know.

@DariushMazlumi
Copy link

same here ):

@oscarsaleta
Copy link

FWIW, check this geerlingguy/macos-virtualbox-vm#24 where they discuss the same issue and seem to have been able to finally install the VM

@xy90321
Copy link

xy90321 commented Sep 24, 2017

since the official macOS app already embedded with a tool to help us make install media, there's no need to manually create install image by those cp commands.

try the commands below which I've verified on my mac and successfully create a VM on my mac host.

  1. create a blank disk image (by using the command provided in Step1.2)

hdiutil create -o /tmp/Sierra.cdr -size 7316m -layout SPUD -fs HFS+J

  1. mount the blank disk image you've created and find out the volume name (normally should be '/Volumes/untitled' )

  2. create the install media by using the official tool

sudo /Applications/Install\ macOS\ Sierra.app/Contents/Resources/createinstallmedia --volume "/Volumes/untitled" --applicationpath /Applications/Install\ macOS\ Sierra.app --nointeraction

notice: replace the content in the double quotation mark with the volume name you found in 2)

  1. unmount the disk image that mounted automatically in 3), which should be named 'Install macOS Sierra'.

  2. convert the disk image to a loadable virtual drive image (by using the command provided in Step 1.11)

hdiutil convert "/tmp/Sierra.cdr.dmg" -format UDTO -o "/tmp/Sierra.iso"

then here you go.

@sghiassy
Copy link

sghiassy commented Sep 25, 2017

Or skip all of this and do it the easy way...

  1. Install Vagrant
  2. In the cli type: vagrant init jhcook/macos-sierra; vagrant up
  3. Grab cup of ☕

P.S: Make sure you have Virtual Box Extension pack installed (link)

@darkn3rd
Copy link

It seems like you have to enable USB3 according to this ticket: https://www.virtualbox.org/ticket/16644

Anyone know how to do that through the command line with VBoxManage?

@drobtitan
Copy link

Download all Mac OS X versions from this place: https://support.apple.com/downloads/macos

@titocr
Copy link

titocr commented Jan 8, 2018

@sghiassy that is cool!

@bwgchung
Copy link

I have experienced getting stuck at the boot up process. I fixed it by setting more than one processor, 8 GB RAM and max graphic RAM.

The solution I got is to set more than one processor to the VM.

@mbigras
Copy link

mbigras commented May 25, 2018

I experienced an error while using the jhcook/macos-sierra box.

==> default: Booting VM...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["startvm", "b8a680e3-383b-44be-be74-8e914a8fb7e5", "--type", "headless"]

Stderr: VBoxManage: error: Implementation of the USB 2.0 controller not found!
VBoxManage: error: Because the USB 2.0 controller state is part of the saved VM state, the VM cannot be started. To fix this problem, either install the 'Oracle VM VirtualBox Extension Pack' or disable USB 2.0 support in the VM settings.
VBoxManage: error: Note! This error could also mean that an incompatible version of the 'Oracle VM VirtualBox Extension Pack' is installed (VERR_NOT_FOUND)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component ConsoleWrap, interface IConsole

You can manually disable USB via VirtualBox but that customization can also be made via the Vagrantfile. Details discussed at:

jonschipp/vagrant#3 (comment)

Vagrant.configure("2") do |config|
  config.vm.box = "jhcook/macos-sierra"
  # https://github.com/jonschipp/vagrant/issues/3#issuecomment-138215720
  config.vm.provider "virtualbox" do |vb|
    vb.customize ["modifyvm", :id, "--usb", "on"]
    vb.customize ["modifyvm", :id, "--usbehci", "off"]
  end
end

@samiyuru
Copy link

If you are trying this with Catalina you can use this script to create the installer media that can be mounted directly on Virtualbox. More information can be found here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment