Updated 04.08.2018 – Fixed the missing xz command in the script
Apple has released a public beta for their latest OS codename Mojave – macOS 10.14. If you posses a relatively new Mac then you can easily download, install and use it. There are a couple of changes that I have noticed (and learned the hard way) in Mojave. Namely the APFS enforcement on the drive you install Mojave to. Even if you initially format the drive with Mac OS Extended , in second stage install the disk gets magically converted to APFS.
This is where I got stuck for a while, since the VirtualBox EFI shell did not know how to even see the APFS formatted drive in order to boot from it. I have came across an excellent project from Alexander Willner – Run macOS 10.14 Mojave on VirtualBox on macOS ( https://github.com/AlexanderWillner/runMacOSinVirtualBox) and even though this is strictly Mac only, it provided me enough clues to replicate his approach and successfully install Mojave on VirtualBox running on Linux.
So here are my steps that I have done
- Creating and obtaining the Mojave ISO yourself if you do not trust the copies on the Internet (I did not upload mine since it is about 10 Gigabytes)
If you already have macOS High Sierra installed in your VirtualBox then you can dive in, !!!!!! MAKE SURE YOU HAVE ENOUGH DISK SPACE ON YOUR MAC !!!!! about 50 Gigabytes shoud be fine, otherwise please follow my previous articles ( https://astr0baby.wordpress.com/2018/07/15/installing-high-sierra-10-13-6-in-virtualbox-5-2-12-on-linux-x86_64/)
Once inside the macOS, make sure you have your AppleID ready, if not create one (takes about 10 minutes). Next open Safari and point it to
https://beta.apple.com/sp/betaprogram/redemption#macos
Login with your AppleID and install the macOS Public Beta Access Utility
Once its installed, you can move next to download the Mojave image
The download can take some time, be patient and remember once its finished DO NOT INSTALL IT ! Just exit the Mojave installer.
Next I have carved out some portions from Alexander’s excellent script here https://github.com/AlexanderWillner/runMacOSinVirtualBox/blob/master/runMojaveVirtualbox.sh
First one is to prepare the Mojave ISO – called image.sh
#!/bin/sh readonly INST_VERS="$(find /Applications -maxdepth 1 -type d -name 'Install macOS*' | wc -l | tr -d '[:space:]')" readonly INST_VER="$(find /Applications -maxdepth 1 -type d -name 'Install macOS*' -print -quit)" readonly INST_BIN="$INST_VER/Contents/Resources/createinstallmedia" readonly DST_DIR="/tmp" readonly VM="macOS-Mojave" readonly VM_DIR="$HOME/VirtualBox VMs/$VM" readonly DST_DMG="$DST_DIR/$VM.dmg" readonly DST_CLOVER="$DST_DIR/${VM}Clover" readonly DST_VOL="/Volumes/$VM" readonly DST_ISO="$DST_DIR/$VM.iso.cdr" ejectAll() { hdiutil info | grep 'Install macOS' | awk '{print $1}' | while read -r i; do hdiutil detach "$i" 2>/dev/null || true done hdiutil info | grep 'OS X Base System' | awk '{print $1}' | while read -r i; do hdiutil detach "$i" 2>/dev/null || true done hdiutil info | grep 'InstallESD' | awk '{print $1}' | while read -r i; do hdiutil detach "$i" 2>/dev/null || true done hdiutil detach "$DST_VOL" 2>/dev/null || true } version="$(/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' "$INST_VER/Contents/Info.plist")" echo "Creating image '$DST_DMG' (be patient, version $version, will need sudo)..." ejectAll hdiutil create -o "$DST_DMG" -size 10g -layout SPUD -fs HFS+J && hdiutil attach "$DST_DMG" -mountpoint "$DST_VOL" && sudo "$INST_BIN" --nointeraction --volume "$DST_VOL" ejectAll hdiutil convert "$DST_DMG" -format UDTO -o "$DST_ISO"
After this script finishes (takes some time) you should have the ISO file ready in /tmp on your virtualized macOS. We can delete the macOS-Mojave.dmg now but keep the macOS-Mojave.iso.cdr
Move the file somewhere since we will be transferring it to our Linux host.
Please note we are using xz in the next script to uncompress the clover image tarball! To get xz on a macOS first install brew like so
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install xz
Next we run a second script that will prepare the Clover boot ISO and inject apfs.efi driver. Script is called clover.sh
#!/bin/bash readonly INST_VER="$(find /Applications -maxdepth 1 -type d -name 'Install macOS*' -print -quit)" curl -Lk https://raw.githubusercontent.com/AlexanderWillner/runMacOSinVirtualBox/master/config.plist ejectAll() { hdiutil info | grep 'Install macOS' | awk '{print $1}' | while read -r i; do hdiutil detach "$i" 2>/dev/null || true done hdiutil info | grep 'OS X Base System' | awk '{print $1}' | while read -r i; do hdiutil detach "$i" 2>/dev/null || true done hdiutil info | grep 'InstallESD' | awk '{print $1}' | while read -r i; do hdiutil detach "$i" 2>/dev/null || true done hdiutil detach "$DST_VOL" 2>/dev/null || true } ejectAll hdiutil attach "$INST_VER/Contents/SharedSupport/BaseSystem.dmg" && cp /Volumes/OS\ X\ Base\ System/usr/standalone/i386/apfs.efi "./apfs.efi" ejectAll curl -Lk https://sourceforge.net/projects/cloverefiboot/files/Bootable_ISO/CloverISO-4533.tar.lzma/download -o clover.tar.lzma sleep 1 xz -d clover.tar.lzma tar xf clover.tar hdiutil detach /Volumes/Clover-v2.4k-4533-X64/ 2>/dev/null || true hdiutil attach Clover-v2.4k-4533-X64.iso hdiutil create -megabytes 16 -fs MS-DOS -volname MojaveClover -o ./clover.dmg hdiutil detach /Volumes/NO\ NAME/ 2>/dev/null || true hdiutil attach ./clover.dmg cp -r /Volumes/Clover-v2.4k-4533-X64/* /Volumes/NO\ NAME/ cp ./config.plist /Volumes/NO\ NAME/EFI/CLOVER/ cp ./apfs.efi /Volumes/NO\ NAME/EFI/CLOVER/drivers64UEFI/ hdiutil detach /Volumes/Clover-v2.4k-4533-X64/ hdiutil detach /Volumes/NO\ NAME/ hdiutil makehybrid -iso -joliet -o ./clover.iso ./clover.dmg
So now we should have clover.iso in our working directory and this should be moved to some location where we put the previous macOS-Mojave.iso.cdr For your convenience I have uploaded the clover.iso for Mojave here https://drop.me/MRqW76
So next we transfer the files to our Linux (scp, samba, which ever way you prefer, I personally setup Samba server on my Linux and upload via SMB from VMs)
2. Setting up VirtualBox for Mojave
Next we will start preparing our VirtualBox environment. I have configured mine like so:
For networking I use the following setup
And this network script that I run on my Linux host (This is my config, your environment will be probably different, but feel free to experiment)
#Setup tap and bridge tunctl -t tap0 -u user ifconfig tap0 up brctl addbr br0 brctl addif br0 enp0s25 vboxnet0 brctl setfd br0 0 ifconfig enp0s25 10.0.2.1 up ifconfig br0 10.0.2.2 netmask 255.255.255.0 broadcast 10.0.2.255 up brctl addif br0 tap0 vboxnet0 ifconfig tap0 0.0.0.0 sysctl net.ipv4.ip_forward=1 iptables -A FORWARD --in-interface enp0s25 -j ACCEPT iptables --table nat -A POSTROUTING --out-interface wlp9s0 -j MASQUERADE
After you create the environment, before you boot the Mojave installer run the following script – assuming you named your VM “Mojave” so change the variable $NAME accordingly
#!/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
Next we boot the Mojave installed (we have copied the Mojave and Clover ISOs right ? )
Once you get to the Disk Utility, erase the new VirtualBox drive with APFS and let it install. After a few minutes it will reboot, now shut down the VM and remove the macOS-Mojave.iso.cdr from the CD drive and replace it with clover.iso
Once we boot the Clover.iso the mouse does not work, no worries the keyboard still does, so you can move the arrow keys to the following
The installation will follow, this time it will take much longer, about 20 – 30 minutes on SSD drive for me.
When the installer exits and goes for reboot the systems gets stuck, just power off the VM and boot as follows (still keep the clover.iso)
Now you should be all set to configure your new Mojave in VirtualBox on Linux !
Again big thanks for to Alexander Willner for his concept ! https://github.com/AlexanderWillner