1. Download a build later than 5.2.12 of Virtualbox 5
  2. Disable System Integrity Protection (SIP)
  3. (Try to) Install Virtualbox
  4. Modify Kexts, rebuild Kernel Extension Cache
  5. Starting Virtualbox
  6. Fix plugin installations if you are using Vagrant and they fail to install
  7. Vagrant and Virtualbox 5.2 working on Mojave!

The new beta of Mac OS X Mojave is mostly stable and so far it has been a good experience… Apart from the recent issues that i have faced with homebrew legacy libraries and this recent problem with Virtualbox, which loads a Kernel Extension that has not yet been approved by Apple.

Here is a temporary solution to get you up and running with the latest Mac OS beta.

Download a build later than 5.2.12 of Virtualbox 5

Go here and download the current Virtualbox Testing version. I got Virtualbox 5.2.15 at this time.

Credit @socratis

Disable System Integrity Protection (SIP)

Yes, yes, I also hate this, but has to be done until Apple refreshes the list of allowed Kernel Extensions to allow VBoxDrv.kext to load properly in Mojave.

  1. Reboot your Mac and hold Command + R (⌘ + R) before it boots.
  2. Keep holding it until you see the progress bar
  3. Wait for it to finish
  4. At the top menu, select Utilities -> Terminal
  5. Enter csrutil disable
  6. Press Enter
  7. Type reboot

After this is solved, do the same steps to re-enable SIP, but type csrutil enable at Step 5.

(Try to) Install Virtualbox

Run the installer.

Installer Running

You will get an error message like this:

Installer Error

No worries, close it and continue.

Modify Kexts, rebuild Kernel Extension Cache

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#Fix Kernel Version

sudo sed -i '' 's/5\.2/5\.3/g' '/Library/Application Support/VirtualBox/VBoxDrv.kext/Contents/Info.plist'
sudo sed -i '' 's/5\.2/5\.3/g' '/Library/Application Support/VirtualBox/VBoxUSB.kext/Contents/Info.plist'
sudo sed -i '' 's/5\.2/5\.3/g' '/Library/Application Support/VirtualBox/VBoxNetAdp.kext/Contents/Info.plist'
sudo sed -i '' 's/5\.2/5\.3/g' '/Library/Application Support/VirtualBox/VBoxNetFlt.kext/Contents/Info.plist'

#Load Kernel Extensions

sudo kextload '/Library/Application Support/VirtualBox/VBoxDrv.kext'
sudo kextload -d '/Library/Application Support/VirtualBox/VBoxDrv.kext' '/Library/Application Support/VirtualBox/VBoxUSB.kext'
sudo kextload -d '/Library/Application Support/VirtualBox/VBoxDrv.kext' '/Library/Application Support/VirtualBox/VBoxNetFlt.kext'
sudo kextload -d '/Library/Application Support/VirtualBox/VBoxDrv.kext' '/Library/Application Support/VirtualBox/VBoxNetAdp.kext'

#Rebuild Kernel Extensions Cache
sudo kextcache -i /

# Start up Virtualbox GUI
Virtualbox &

Credit @IPV6Freely

Starting Virtualbox

Using the GUI will give you an error:

GUI Error

However, you should be able to start VirtualBox using the Terminal:

1
Virtualbox &

Fix plugin installations if you are using Vagrant and they fail to install

Before I had this, which worked before Mojave and in Linux too:

1
2
3
4
5
6
7
8
9
10
required_plugins = %w(vagrant-share vagrant-vbguest vagrant-disksize vagrant-proxyconf)
plugins_to_install = required_plugins.select { |plugin| not Vagrant.has_plugin? plugin }
if not plugins_to_install.empty?
  puts "Installing plugins: #{plugins_to_install.join(' ')}"
  if system "vagrant plugin install #{plugins_to_install.join(' ')}"
    exec "vagrant #{ARGV.join(' ')}"
  else
    abort "Installation of one or more plugins has failed. Aborting."
  end

This caused issues:

1
2
3
Exec error: fork/exec /opt/vagrant/embedded/bin/ruby: argument list too long
Exec error: fork/exec /opt/vagrant/embedded/bin/ruby: argument list too long
Exec error: fork/exec /opt/vagrant/embedded/bin/ruby: argument list too long

The solution was to reformulate the plugin installation code in the Vagrantfile like this:

1
2
3
4
5
6
7
8
9
required_plugins = %w(vagrant-share vagrant-vbguest vagrant-disksize vagrant-proxyconf)
return if !Vagrant.plugins_enabled?

plugins_to_install = required_plugins.select { |plugin| !Vagrant.has_plugin? plugin }

if plugins_to_install.any?
  system "vagrant plugin install #{plugins_to_install.join(' ')}"
  exit system 'vagrant up'

Credit to @nuxy for this fix

Vagrant and Virtualbox 5.2 working on Mojave!

All fixed