Skip to content

Instantly share code, notes, and snippets.

@cristianadam
Last active October 12, 2024 09:30
Show Gist options
  • Save cristianadam/f976b15ceb86cbc011bbb52c267bd128 to your computer and use it in GitHub Desktop.
Save cristianadam/f976b15ceb86cbc011bbb52c267bd128 to your computer and use it in GitHub Desktop.
Push-button installer of macOS on VirtualBox

Push-button installer of macOS on VirtualBox

https://github.com/myspaghetti/macos-virtualbox

macos-guest-virtualbox.sh is a Bash script that creates a macOS virtual machine guest on VirtualBox with unmodified macOS installation files downloaded directly from Apple servers.

On Windows you need cygwin to run it. https://www.cygwin.com/ Make sure you have wget package installed.

Then with https://github.com/transcode-open/apt-cyg you can get the dependencies that the macos-guest-virtualbox.sh needs:

bash coreutils gzip unzip wget xxd dmg2img virtualbox

Then it's just a matter of running:

$ ./macos-guest-virtualbox.sh

And following the instructions.

AMD Users

For my Ryzen 9 CPU I had to modify the script so that macOS won't complain:

diff --git a/macos-guest-virtualbox.sh b/macos-guest-virtualbox.sh
index 9a3b908..de82e0b 100755
--- a/macos-guest-virtualbox.sh
+++ b/macos-guest-virtualbox.sh
@@ -638,7 +638,8 @@ print_dimly "stage: configure_vm"
 VBoxManage modifyvm "${vm_name}" --cpus "${cpu_count}" --memory "${memory_size}" \
  --vram "${gpu_vram}" --pae on --boot1 none --boot2 none --boot3 none \
  --boot4 none --firmware efi --rtcuseutc on --chipset ich9 ${extension_pack_usb3_support} \
- --mouse usbtablet --keyboard usb --audiocontroller hda --audiocodec stac9221
+ --mouse usbtablet --keyboard usb --audiocontroller hda --audiocodec stac9221 \
+ --cpu-profile "Intel Xeon X5482 3.20GHz"

 VBoxManage setextradata "${vm_name}" \
  "VBoxInternal2/EfiGraphicsResolution" "${resolution}"

Installing VirtualBox guest additions

Is we mount VBoxGuestAdditions.iso we can have access to the MacOS guest additions. Unfortunately with macOS Catalina they cannot be installed as easily as before.

One needs to disable "System Integrity Protection" (SIP).

$ csrutil status

Will show that SIP is enabled.

This is done by booting into recovery tool, Unfortunately it doesn't work as easy as MacKey-R.

You need to reboot and go into VirtualBox's BIOS by pressing F2, then "Boot Manager" and then "EFI Internall Shell".

Press "Esc" to skip startup.nsh then type:

fs2:
fs2:\> dir
fs2:\> cd <LONG-GUID-DIRECTORY>
fs2:\<LONG-GUID-DIRECTORY>\> boot.efi

You will be booted up into "macOS Utilities". There in the "Utilities" menu entry select "Terminal" and run:

$ csrutil disable
$ reboot

After booting up in macOS, in Terminal run these commands (from #19047)

$ sudo mount -uw /
$ sudo chown :admin /System/Library/Extensions/
$ sudo chmod 775 /System/Library/Extensions/

Then run VBoxDarwinAdditions.pkg to install the VirtualBox guest additions! Clipboard between host and guest will work now!

Optimal CPU values

VirtualBox for macOS doesn't do hyperthreading for every CPU in settings you get a thread. I have tested the virtual machine with 12 CPUs and 16 GB RAM.

With 16 CPUs the VM didn't start.

I noticed that with 4 CPUs the interface and overall performance is better than with 8 or 12 CPUs.

For the known limitations of the Virtual Box macOS guests see the Chapter 14 of the VirtualBox manual.

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