I tried to install VirtualBox on macOS High Sierra, but I got an error about kernel drivers, system extensions, and kernel modules not being installed. The VirtualBox installer fails with “The installation failed” where it “encountered an error that caused the installation to fail.”

This guide has been updated for macOS Mojave as well.

Go to System Preferences > Security & Privacy. Click the ‘Allow’ button at the bottom. Re-run the installer. More detailed instructions are below.

VirtualBox has an error when installing.

Run the VirtualBox installer just like any other installer.

You might see a prompt from macOS about not allowing unsecure system extensions. You can click ‘Next’ for now.

After reaching the end, installation will fail with the message above.

Navigate to System Preferences > Security & Privacy. At the bottom of the window, you should see a message saying “System software from developer, ‘Oracle, America, Inc.‘ was blocked from loading.”

Click the lock in the bottom left corner, enter your password

Click ‘Allow’ next to the ”blocked from loading” message.

Re-run the VirtualBox installer. It should succeed.

How to add a shared folder for Ubuntu on a macOS High Sierra Host?

Here’s how to share files between a Ubuntu virtual machine and macOS High Sierra on VirtualBox.

Download, set up your VM. See above.

Open settings for the VM. Click the “Shared Folders” tab. Add your folder and select Yes for “Auto-mount”

Run the VM

While the VM is running, in the Mac menu bar go to Devices > Optical Drives > Choose disk image…

Select the VirtualBox Guest Additions image, for me this is located at /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso. Once the Choose disk image… option was selected, you were probably shown a file picker. Press Command-Shift-G and then type in that file to choose the VBoxGuesAdditions.iso.

You might need to force mount/unmount. You’ll be prompted by VirtualBox if this is necessary.

Restart your VM.

Run the following command to install prerequisites for the Mac VirtualBox Guest Additions: sudo apt-get -y install gcc make linux-headers-$(uname -r)

Then run sudo /media/cdrom/VBoxLinuxAdditions.run to install the Guest Additions