With the major release of VirtualBox 6.1 came the support to APFS which was problematic before especially for virtualizing macOS Mojave or Catalina. I have realized this is a major improvement and decided to post yet another macOS Movaje installation procedure under VirtualBox 6.1 and Linux x86_64.
The Changelog for VirtualBox 6.1 is here https://www.virtualbox.org/wiki/Changelog-6.1 and lurking at the end is the small note which matters
EFI: Added support for booting from APFS
So lets move on and do a quick recap of what needs to be done. We need to get macOS Mojave obviously in an ISO format first onto our Linux machine, there are several methods how to do this (macOS is available for free from App-store ) but you need a macOS to do this or you can use an ISO created for this especially. Here is a good source how to do this http://osxdaily.com/2018/09/29/download-full-macos-mojave-installer/
Or you can get a working copy here https://gofile.io/?c=sjlJRS
We create the Mojave VirtualBox template and name it Mojave, make sure to set the following
- RAM > 2048 MB
- 2 CPUs minimum
- Chipset – ICH9
- Pointing Device – USB Tablet
- Display 128 MB Video Memory + Enable 3d acceleration
- Storage – Mojave.iso
- Network (I use Host-only-Adapter vboxnet0)
- USB – USB 3.0 xHCI
Network – vboxnet0
- Networking scripts needed for TCP/IP if we use vboxnet0 under VirtualBox 6.1
- apt-get install uml-utilities bridge-utils
- IMPORTANT – load this script as root only after you run VirtualBox so that the vboxnet0 gets created, next time when you reboot either make sure this is automated or keep in mind that you need to first stat VirtualBox console, then run the below script as root for the vboxnet0 network to be ready.
# Typical networking script used along with VirtualBox # Where the internet connected interface is the Wireless wlan0 # This can of course be customized to ones needs # This script needs to be executed prior the simulator start as root tunctl -t tap0 -u user ifconfig tap0 up brctl addbr br0 brctl setfd br0 0 ifconfig br0 10.0.2.2 netmask 255.255.255.0 broadcast 10.0.2.255 up brctl addif br0 tap0 ifconfig tap0 0.0.0.0 sysctl net.ipv4.ip_forward=1 iptables --table nat -A POSTROUTING --out-interface wlan0 -j MASQUERADE
Once you are done, before booting Mojave, save the below scripts on your system and execute them, change the $NAME variable to whatever you have called Mojave in VirtualBox and choose the VM_RES value to use (it cannot be changed in the VM)
1680×1050 resolution preset script to be executed once we create the VM Mojave template
#!/bin/bash readonly VM_RES="1680x1050" readonly NAME="Mojave" VBoxManage modifyvm "$NAME" --usbxhci on --firmware efi --chipset ich9 --mouse usbtablet --keyboard usb VBoxManage setextradata "$NAME" "CustomVideoMode1" "${VM_RES}x32" VBoxManage setextradata "$NAME" VBoxInternal2/EfiGraphicsResolution "$VM_RES" VBoxManage modifyvm "$NAME" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff VBoxManage setextradata "$NAME" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3" VBoxManage setextradata "$NAME" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0" VBoxManage setextradata "$NAME" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple" VBoxManage setextradata "$NAME" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" VBoxManage setextradata "$NAME" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
1280×1024 resolution preset script to be executed once we create the VM Mojave template
#!/bin/bash readonly VM_RES="1280x1024" readonly NAME="Mojave" VBoxManage modifyvm "$NAME" --usbxhci on --firmware efi --chipset ich9 --mouse usbtablet --keyboard usb VBoxManage setextradata "$NAME" "CustomVideoMode1" "${VM_RES}x32" VBoxManage setextradata "$NAME" VBoxInternal2/EfiGraphicsResolution "$VM_RES" VBoxManage modifyvm "$NAME" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff VBoxManage setextradata "$NAME" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3" VBoxManage setextradata "$NAME" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0" VBoxManage setextradata "$NAME" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple" VBoxManage setextradata "$NAME" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" VBoxManage setextradata "$NAME" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC"
Next its pretty straight forward, boot Mojave, load Disk Utility, Erase the VM HDD and let the installer run, this time VirtualBox has no issues with EFI APFS boot, so no Clover.iso needed :)
Setup network – since I don’t run DHCPd in my virtual networks I choose the manual IP configuration. I have used for the Mojave en0 the following values
- IP 10.0.2.12
- Netmask 255.255.255.0
- Gateway 10.0.2.2
- DNS 8.8.8.8
disable Apple telemetry (location services and usage statistics during setup) and we are ready to start testing :) Do not upgrade to Catalina (it works, but the latest Catalina does not boot in VirtualBox yet) , however the normal system/software updates for Mojave work fine
Then system will reboot (takes some time, so be patient) ; all is smooth now and no need to switch between EFI shells anymore !
Reboot one more time, this time longer estimated time to finish
And after about 30 minutes (SSD drive) the fresh Mojave updated comes up