Installing Mojave 10.14 Beta in VirtualBox 5.2.16 on Linux x86_64

As of VirtualBox 6.1 Clover.iso is not needed, since VirtualBox supports EFI APFS boot now https://astr0baby.wordpress.com/2019/12/19/mojave-on-virtualbox-6-1-linux/

Update 25.09.2018https://astr0baby.wordpress.com/2018/09/25/running-macos-mojave-10-14-on-virtualbox-5-2-18-on-linux-x86_64/

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

  1. 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://mega.nz/#!ewsiWYDL!r4qILNC08O8lGjBC9GgvMHAR096CIVy2RMP6MwZ3-KA

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

Advertisement

About astr0baby

Please run Adblock or similar... we have been told to do so since Carl Sagan wrote the Contact .
This entry was posted in Uncategorized. Bookmark the permalink.

22 Responses to Installing Mojave 10.14 Beta in VirtualBox 5.2.16 on Linux x86_64

  1. billiousprime says:

    Excellent guide!, thank you. FWIW– I found that I only needed about 6G to make the Mojave iso. It also seems that the upstream source (Alexander Willner?) the clover script uses has changed artwork and screen resolution to something different than what you used in your post. The screen will tear and look like snow if booted. I downloaded your clover.iso and it worked like a charm.

    Thanks again.

  2. will says:

    stuck in logo…could you please give me some ideas…

  3. Alex says:

    Looks like a great tutorial, thanks. Alas, the macOS-Mojave.iso.cdr that I created does not boot. The boot process ends up in the interactive UEFI shell instead. The script that generates the iso runs fine. For testing whether the new Mojave VM can boot at all, I tried to boot clover.iso. This worked, but of course does not help much without booting the Mojave image first. Any idea?

  4. Peter says:

    Hello

    Thanks for writing this up. I manage to get as far as rebooting with clover.iso mounted, but then nothing happens. Screen stays black.

    Any tips would surely be appreciated!

    Peter

    • astr0baby says:

      Can you please describe exactly what steps you did ? Hard to help from the above info

      • Peter says:

        Hello

        Tx for your quick reply! I had the machine Version as “Mac OS X (64 bit)”. Switching to “macOS 10.13 HIgh Sierra (64 bit)” fix it. Installation is continuing now.

        Peter

  5. Hello,
    .
    after an update virtualbox from 5.2.22 (Opensuse) to 6.0.4 (Oracle) on my host OpenSuse 15 works Mojave 10.14.3 normaly, when I boot fresh. Restart of an snapshot: The mausintegration is lost. If I click in to the vb-window, vb will catch the maus. After ok no maus is visible and acting. Do you have an idea, what this could be and what should i do to repair.

    sincerly yours

    Fred

    • astr0baby says:

      Hello Fred,

      How is your mouse configured in Virtualbox for Mojave ? Should be set to USB-Tablet in System>Motherboard and USB3 xHCI under USB.
      I have never restored from snapshot on Mojave, will try to see if I can re-create your case.

    • astr0baby says:

      I have created a snapshot of Mojave (10.14.3) and restored it, and mouse works fine (Linux Mint 19; VirtualBox 6.0.4) I could not reproduce your symptoms. Maybe do a clean install under 6.0.4 and check if that is different.

  6. lockywolf says:

    Nginx bad gateway on clover.iso download.

  7. Pingback: macOS Mojave 10.14 in VirtualBox on Linux | Tech Booze

  8. thefederalbureauofinvestigation says:

    Thank you so much for this post. It worked first time for me. As it turns out I don’t need an external mouse. My laptop’s (Thinkpad P50) touch pad works just fine inside the VM. I’m running Ubuntu Mate 18.04 and VirtualBox 5.2.32.

  9. Pingback: macOS Mojave 10.14 in VirtualBox on Linux | Tech Land

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.