geerlingguy / macos-virtualbox-vm

Instructions and script to help you create a VirtualBox VM running macOS.
MIT License
2.55k stars 313 forks source link

Install Guest Additions on macOS 10.15 Catalina. #79

Open end2endzone opened 3 years ago

end2endzone commented 3 years ago

On macOS 10.15 Catalina, Guest Additions cannot be installed by default. The installation cannot be completed as normal because the OS now require packages to be digitally signed. To get around this security limitation, you need to disable multiple security features in order to install the package. I think this applies to macOS 10.14 as well.

I managed to install Guest Additions using VirtualBox version 6.1.16 on Windows 7 to share the clipboard values between the host and the guest. If someone else wants to install this, here is the whole process:

Disable Gatekeeper

  1. Be sure to exit System Preferences on your Mac.
  2. Open a Terminal
  3. Enter the command sudo spctl --master-disable.

Source: How to open apps from unidentified developers on Mac in macOS Catalina

Check Gatekeeper is disabled

  1. Click on System Preferences on your Mac Dock.
  2. Choose Security & Privacy.
  3. Look at Allow apps download from:, it should be set to Anywhere. If it is, you are done.
  4. If not, click the lock icon at the bottom left of the screen.
  5. Choose the Anywhere option under Allow apps downloaded from. Prior to making the change, this option wasn't available.
  6. Click the unlocked lock again to keep the change.

Disable SIP (System Integrity Protection)

  1. Restart your computer in Recovery mode.
  2. Launch Terminal from the Utilities menu.
  3. Run the command csrutil disable .
  4. Restart your computer.

I tried pressing F12, F8 and even ESC key in order to configure VirtualBox to boot into the EFI shell but was not able to do so. In the end, this comment from issue 46 had the solution:

  1. In your VM's terminal enter the following command to reboot in recovery mode: sudo nvram recovery-boot-mode=unused && sudo shutdown -r now
  2. Once in recovery mode open a terminal in Utilities->Terminal.
  3. Run the commands you want like: csrutil disable spctl kext-consent add VB5E2TV963 (note the last command is explained in steps below)
  4. Enter the following command to exit recovery mode: nvram -d recovery-boot-mode && shutdown -r now
  5. And you'll get back into normal macOS.

Check SIP is disabled

You can verify that SIP is disabled with the command: csrutil status which should display: System Integrity Protection status: disabled..

Allow Oracle identifier for kext

  1. Restart your computer in Recovery mode. Refer to previous section to know how to do this.
  2. Launch Terminal from the Utilities menu.
  3. Run the command spctl kext-consent add VB5E2TV963 .
  4. Restart your computer.

VB5E2TV963 is the code for oracle.

Source: Install problem 10.14.5 vBox 6.0

Change ownership and permissions on filesystem

Enable writing to /System/Library/Extensions/.

In your VM's terminal enter the following commands:

sudo mount -uw /
sudo chown :admin /System/Library/Extensions/
sudo chmod 775 /System/Library/Extensions/

Source: Guest Additions not installing on macOS 10.15 Catalina guests

Install Guest Additions

At this point, the installation of Guest Addition should succeed. Proceed with normal installation instructions.

  1. On VirtualBox emulation window, click on Devices menu.
  2. Select Insert Guest Additions CD image....
  3. In your VM, click on the new CD image on the desktop.
  4. Click on VBoxDarwinAdditions.pkg.
  5. Follow the instructions on screen.
  6. A reboot is required after the installation.

Check clipboard sharing is working

Check that clipboard is shared between the host and the guest.

  1. On VirtualBox emulation window, click on Devices menu.
  2. Select menu Shared Clipboard, Bidirectional.
  3. In your VM, open a terminal.
  4. Select text.
  5. Right-click on the selected text and select Copy.
  6. On your host, open a note taking appplication.
  7. Right-click and select Paste.

Revert disabled security features

Enable Gatekeeper

  1. Be sure to exit System Preferences on your Mac.
  2. Open a Terminal
  3. Enter the command sudo spctl --master-enable.

Enable SIP

  1. Restart your computer in Recovery mode.
  2. Launch Terminal from the Utilities menu.
  3. Run the command csrutil enable .
  4. Restart your computer.
codeclinic commented 3 years ago

Thanks for this info. I've tried so many different combinations and this is the first and only one that actually works.

Should we revert the /System/Library/Extensions/ back to its original ownership and permissions? If so, do you know what they should be set to?

Also, do you know if the VBox GA's will persist if I update the OS to Big Sur? I know that installing Vbox GA's on Big Sur is currently not-doable, so not sure if it's safe to update.

tHANKS:

end2endzone commented 3 years ago

I'm glad it helped you.

I did not tried to revert permission changes on /System/Library/Extensions/. I am using this VM as a test machine so I don't really care about vulnerabilities related to this change.

I do not have plans to upgrading to Big Sur. Like you said, I have read the same posts about compatibility problem with GA on Big Sur. I don't know if the installation will persist. Actually the files may still be available but they may not load. Installing on Catalina and then upgrading to Big Sur might be a possible workaround. If you every try, keep me posted.

NoWhereMan1979 commented 3 years ago

I did instructions but what i got was share clip board. no full screen, no shared folders. tested on Catalina in Virtual Box 6.1.22. Thanks for help.

end2endzone commented 3 years ago

Hi. I am sorry but I did not tried the Shared Folder feature of VirtualBox so I cannot help you with that.

What I did for file sharing... If you need to share files from macOS, you can enable samba file share from within macos directly. You can search for mac enable file share samba on google for multiple instructions guide. For example, this or this seems to be good starting points.

To enable a higher resolution or full screen... You need to change settings in Virtualbox to enable custom resolutions. Since I am on Windows, I executed the following batch file which enabled 1600x900 resolution :

@echo off
cd /d "C:\Program Files\Oracle\VirtualBox\"

set VM_NAME=MacOS Catalina 10.15

REM The following might be required on AMD CPU
REM See https://www.wikigain.com/install-macos-catalina-on-virtualbox-on-windows/
VBoxManage.exe modifyvm "%VM_NAME%" --cpu-profile "Intel Xeon X5482 3.20GHz"

REM Change default resolution of 1024x768
REM https://www.professionaltutorial.com/fix-macos-catalina-screen-resolution-on-virtualbox/
REM VBoxManage setextradata "%VM_NAME%" VBoxInternal2/EfiGraphicsResolution 1024x768
REM VBoxManage setextradata "%VM_NAME%" VBoxInternal2/EfiGraphicsResolution 1920x1080
VBoxManage setextradata "%VM_NAME%" VBoxInternal2/EfiGraphicsResolution 1600x900
pause

You need to change the variable VM_NAME to the actual name of of your virtual machine inside VirtualBox. Mine was named MacOS Catalina 10.15. I prefer having a windowed maximum resolution of 1600x900 instead of full screen. You might only have to change 1600x900 by 1920x1080 to enable full screen on your side.

I have left the web site references were I have found this information. Feel free to take a look at them. They might explain in details what all these commands are doing.

NoWhereMan1979 commented 3 years ago

Hi. I am sorry but I did not tried the Shared Folder feature of VirtualBox so I cannot help you with that.

What I did for file sharing... If you need to share files from macOS, you can enable samba file share from within macos directly. You can search for mac enable file share samba on google for multiple instructions guide. For example, this or this seems to be good starting points.

To enable a higher resolution or full screen... You need to change settings in Virtualbox to enable custom resolutions. Since I am on Windows, I executed the following batch file which enabled 1600x900 resolution :

@echo off
cd /d "C:\Program Files\Oracle\VirtualBox\"

set VM_NAME=MacOS Catalina 10.15

REM The following might be required on AMD CPU
REM See https://www.wikigain.com/install-macos-catalina-on-virtualbox-on-windows/
VBoxManage.exe modifyvm "%VM_NAME%" --cpu-profile "Intel Xeon X5482 3.20GHz"

REM Change default resolution of 1024x768
REM https://www.professionaltutorial.com/fix-macos-catalina-screen-resolution-on-virtualbox/
REM VBoxManage setextradata "%VM_NAME%" VBoxInternal2/EfiGraphicsResolution 1024x768
REM VBoxManage setextradata "%VM_NAME%" VBoxInternal2/EfiGraphicsResolution 1920x1080
VBoxManage setextradata "%VM_NAME%" VBoxInternal2/EfiGraphicsResolution 1600x900
pause

You need to change the variable VM_NAME to the actual name of of your virtual machine inside VirtualBox. Mine was named MacOS Catalina 10.15. I prefer having a windowed maximum resolution of 1600x900 instead of full screen. You might only have to change 1600x900 by 1920x1080 to enable full screen on your side.

I have left the web site references were I have found this information. Feel free to take a look at them. They might explain in details what all these commands are doing.

Thank a lot. It is better than 1024x768 that i was stuck in.☺

ekawahyu commented 3 years ago

I am not able to enter recovery mode with this: sudo nvram recovery-boot-mode=unused && sudo shutdown -r now

is there any other way to enter recovery mode? or am I doing anything wrong?

DovahBrownies commented 3 years ago

I am not able to enter recovery mode with this: sudo nvram recovery-boot-mode=unused && sudo shutdown -r now

is there any other way to enter recovery mode? or am I doing anything wrong?

To Enter Recovery Mode Without VM Terminal or Recovery CDs

  1. Make sure you insert the MacOS installation disk (In this case, Catalina): image

  2. Restart your virtual MacOS: image

  3. When the shutdown cycle completes and a startup cycle begins (when the terminal goes completely black), start pressing the boot menu key. It could be either ESC1, F81, or F12. You'll be presented with a BIOS-like menu. Choose Boot Manager: image

  4. Here you'll want to select the VBOX CD-ROM to boot from the Catalina disk we inserted in step 1: image

  5. After a few moments you'll be taken to the recovery menu. Restarting your Virtual MacOS will reboot the machine back into its normal state.

I can't believe this wasn't laid out in clear steps before. I had to figure this out myself from prior experiences. All other posts or answer suggest using a VM terminal or downloading a recovery disk.

ekawahyu commented 3 years ago

@DovahBrownies Thank you for this instruction!

tuanpht commented 3 years ago

I've tried this, it works for sharing clipboards

https://stackoverflow.com/a/54186352/6595322

nojsja commented 3 years ago

After do all above, my vm stucks on boot, any suggestions?

Alex533704 commented 2 years ago

Hello,i followed all steps above but when i try to inject GuestAdditons into macOS i still have a error message:cannot insert optical disk GuestAddition in Virtual Machine

I' m using macOS catalina in VirtualBox.

Please help me

changken commented 2 years ago

Thanks to your tutorial!

hurelhuyag commented 2 years ago

Only shared clipboard working. Is anyone get a working shared folder?

nalsminator commented 2 years ago

imagen Thanks man!

boganiLuca commented 5 months ago

Just a tip for who might end up here while trying to install Guest additions on Monterey: every thing listed here is a good suggestion, but there's one small step that seems to make the installation impossible. Since from Monterey and up (or maybe Big Sur), the /System/Library folder is read only for everyone except system, these commands won't work anymore:

sudo mount -uw /
sudo chown :admin /System/Library/Extensions/
sudo chmod 775 /System/Library/Extensions/

I found no way to get around this: I even got an old copy of BatChmod that seemed to be able to change ownership and permissions on the Extensions folder, but it probably just messed up the ownership. Some other apps warned me of this problem in the Library, and repairing the disk through DiskUtility had no effect, so be warned that trying to chown/chmod that folder might have dangerous side effects. In any case, those three commands kept on failing, same as the Additions installation itself: I resigned myself to work with just the file sharing through samba (not with shared folder) and no clipboard.