Last active
February 18, 2022 17:53
-
-
Save DanielGibson/896a16244a6b21eb2ede35054cab387d to your computer and use it in GitHub Desktop.
How to install OSX in VirtualBox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| * On a Mac/other OSX VM, get El Capitan in AppStore | |
| * Similar for High Sierra, see https://gist.github.com/agentsim/00cc38c693e7d0e1b36a2080870d955b#gistcomment-2214881 | |
| for the changed script. | |
| You might have to reboot your Mac after Downloading High Sierra in the AppStore, | |
| in case the first hdiutil attach ... step fails. | |
| * (Create install ISO with following script:) | |
| #!/bin/bash | |
| # Mount the Installer image | |
| hdiutil attach /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app | |
| # Create El Capitan sparseimage of 7316mb with a Single Partition - Apple Partition Map | |
| hdiutil create -o /tmp/ElCapitan -size 7316m -layout SPUD -fs HFS+J -type SPARSE | |
| # Mount the El Capitan sparseimage | |
| hdiutil attach /tmp/ElCapitan.sparseimage -noverify -nobrowse -mountpoint /Volumes/install_build | |
| # Restore the Base System into the El Capitan Blank sparseimage | |
| asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase | |
| # Remove Packages link and replace with actual files | |
| rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages | |
| cp -rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/ | |
| # Copy El Capitan installer dependencies | |
| cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist | |
| cp -rp /Volumes/install_app/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/BaseSystem.dmg | |
| # Unmount the installer image | |
| hdiutil detach /Volumes/install_app | |
| # Unmount the Base System image | |
| hdiutil detach /Volumes/OS\ X\ Base\ System/ | |
| # Optimise Sparseimage Size | |
| hdiutil compact /tmp/ElCapitan.sparseimage | |
| hdiutil resize -size min /tmp/ElCapitan.sparseimage | |
| # Convert the ElCapitan spareseimage to ISO/CD master | |
| hdiutil convert /tmp/ElCapitan.sparseimage -format UDTO -o /tmp/ElCapitan.iso | |
| # Rename the ElCapitan ISO image and move it to the desktop | |
| mv /tmp/ElCapitan.iso.cdr ~/Desktop/'EC 10.11.0.iso' | |
| # Delete ElCapitan.sparseimage file | |
| rm -f /tmp/ElCapitan.sparseimage | |
| ###### EOF ###### | |
| * Copy resulting ISO to VM host | |
| * New VM, OSX El Capitan (or whatever), ... | |
| * Tell the VM it's a Mac (replace "El_Capitan" with your VM name): | |
| VBoxManage modifyvm "El_Capitan" --cpuidset 00000001 000306a9 04100800 7fbae3ff bfebfbff | |
| VBoxManage modifyvm "Your Virtual Machine Name" --cpu-profile "Intel Core i7-6700K" // maybe line before is not needed? | |
| VBoxManage setextradata "El_Capitan" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "MacBookPro11,3" | |
| VBoxManage setextradata "El_Capitan" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0" | |
| VBoxManage setextradata "El_Capitan" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Mac-2BD1B31983FE1663" | |
| VBoxManage setextradata "El_Capitan" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" | |
| VBoxManage setextradata "El_Capitan" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1 | |
| * Mount ISO, install (Create Partition with Utilities Menu -> Disk Utility -> Erase) | |
| * Set resolution via VM's EFI: | |
| VBoxManage setextradata "El_Capitan" "VBoxInternal2/EfiGopMode" <N> | |
| // <N> can be one of 0,1,2,3,4,5 for 640x480, 800x600, 1024x768, 1280x1024, 1440x900, 1920x1200 | |
| - Apparently in VirtualBox 5.2.0 and newer you can set a custom resolution, like | |
| VBoxManage setextradata "El_Capitan" "VBoxInternal2/EfiGraphicsResolution" "1920x1080" | |
| For El Capitan (and probably other older OSX versions), installation will fail nowadays because their | |
| package signatures expired ("No packages were eligible for install"). | |
| Workaround: Reset date to 2018 or something, can be done in installer: | |
| Utilities Menu -> Terminal, there use the date command, like | |
| # date 010120302018 | |
| Then finish the installation as usual |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment