How To Use macos-guest-virtualbox.sh To Install macOS On VirtualBox

This article will tell you how to install macOS ( “HighSierra” “Mojave” “Catalina” ) on VirtualBox virtual machine using the Github open source push-button installer file macos-guest-virtualbox.sh.

1. Steps To Install macOS On VirtualBox Virtual Machine Using macos-guest-virtualbox.sh.

  1. The below steps are based on macOS and Linux, if you use Windows you can go to section 2 of this article, Windows users need Cygwin to run the script.
  2. Before you start to install, you had better change the VirtualBox default machine folder to the folder that saves this script file, you can refer to the article How To Copy VirtualBox Virtual Machine To Another Computer.
  3. Go to the page https://github.com/myspaghetti/macos-virtualbox/releases Assets section to download the file macos-guest-virtualbox.sh.
  4. After download, go to the download directory and run the command chmod +x ./macos-guest-virtualbox.sh to add the executable permission to the file.
    $ ls -l *.sh
    [email protected] 1 songzhao  staff  85093 Jan  2 10:18 macos-guest-virtualbox.sh
    (base) songs-MacBook-Pro:Downloads songzhao$ 
    (base) songs-MacBook-Pro:Downloads songzhao$ 
    (base) songs-MacBook-Pro:Downloads songzhao$ chmod +x ./macos-guest-virtualbox.sh
    (base) songs-MacBook-Pro:Downloads songzhao$ 
    (base) songs-MacBook-Pro:Downloads songzhao$ 
    (base) songs-MacBook-Pro:Downloads songzhao$ ls -l *.sh
    [email protected] 1 songzhao  staff  85093 Jan  2 10:18 macos-guest-virtualbox.sh
  5. Now run the script file ./macos-guest-virtualbox.sh again to install the macOS on the VirtualBox virtual machine, but you may encounter the below error.
    (base) songs-MacBook-Pro:Downloads songzhao$ ./macos-guest-virtualbox.sh 
    Please execute this script with Bash 4.3 or higher, or zsh 5.5 or higher.
    macOS detected. Make sure the script is not executed with the default /bin/bash
    which is version 3. Explicitly type the executable path, for example for zsh:
        /path/to/5.5/zsh macos-guest-virtualbox.sh
  6. To fix the above error, you should install the latest bash version, you can read the article How To Update Bash Version On macOS to learn more.
  7. After you install the latest bash version you should edit the macos-guest-virtualbox.sh file and use the latest bash version (for example /usr/local/bin/bash) to replace the old bash version( /bin/bash ) in the first line of the macos-guest-virtualbox.sh file.
  8. When you run the shell file macos-guest-virtualbox.sh again, you may encounter the below errors.
    macOS detected.
    Please use a package manager such as homebrew, pkgsrc, nix, or MacPorts
    Please make sure the following packages are installed and that
    their path is in the PATH variable:
        bash  coreutils  dmg2img  gzip  unzip  wget  xxd
    Please make sure Bash and coreutils are the GNU variant.
  9. The above error means you need to install bash, coreutils, dmg2img, gzip, unzip, wget, xxd packages using the brew command.
  10. First, run the command brew list to get all the installed brew packages.
    $ brew list
    ==> Formulae
    bash		gettext		maven		ntfs-3g		tomcat
    geckodriver	icu4c		node		openjdk		tree
  11. Then run the command brew install coreutils to install the coreutils package.
    $ brew list
    ==> Formulae
    bash		gettext		maven		ntfs-3g		tomcat
    geckodriver	icu4c		node		openjdk		tree
    (base) songs-MacBook-Pro:Downloads songzhao$ brew install coreutils
    Running `brew update --preinstall`...
    ==> Auto-updated Homebrew!
    Updated 1 tap (homebrew/core).
    ==> Updated Formulae
    Updated 4 formulae.
    
    ==> Downloading https://ghcr.io/v2/homebrew/core/gmp/manifests/6.2.1_1
    ######################################################################## 100.0%
    ==> Downloading https://ghcr.io/v2/homebrew/core/gmp/blobs/sha256:5ee7a460668864c28e541db15420e1480c3d31c5f216797a453a5310106fbc97
    ==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:5ee7a460668864c28e541db15420e1480c3d31c5f216797a453a5310106f
    ######################################################################## 100.0%
    ==> Downloading https://ghcr.io/v2/homebrew/core/coreutils/manifests/9.0
    ######################################################################## 100.0%
    ==> Downloading https://ghcr.io/v2/homebrew/core/coreutils/blobs/sha256:9b24df176ef9ec342e83af6880c27e0235e4fcc436d0143fb37eb24695de51a6
    ==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:9b24df176ef9ec342e83af6880c27e0235e4fcc436d0143fb37eb24695de
    ######################################################################## 100.0%
    ==> Installing dependencies for coreutils: gmp
    ==> Installing coreutils dependency: gmp
    ==> Pouring gmp--6.2.1_1.catalina.bottle.tar.gz
    🍺  /usr/local/Cellar/gmp/6.2.1_1: 21 files, 3.3MB
    ==> Installing coreutils
    ==> Pouring coreutils--9.0.catalina.bottle.tar.gz
    ==> Caveats
    Commands also provided by macOS and the commands dir, dircolors, vdir have been installed with the prefix "g".
    If you need to use these commands with their normal names, you can add a "gnubin" directory to your PATH with:
      PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
    ==> Summary
    🍺  /usr/local/Cellar/coreutils/9.0: 480 files, 12.7MB
    ==> Running `brew cleanup coreutils`...
    Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
    Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
    ==> Caveats
    ==> coreutils
    Commands also provided by macOS and the commands dir, dircolors, vdir have been installed with the prefix "g".
    If you need to use these commands with their normal names, you can add a "gnubin" directory to your PATH with:
      PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
    
  12. Install the other missing packages using the command brew install <package_name>.
  13. After installing all the required packages, you can run the command ./macos-guest-virtualbox.sh to start the macOS VirtualBox virtual machine installation process.
  14. It will start a separate virtual machine’s Window and you can see the installation output text on the virtual machine’s screen.
  15. The macOS virtual machine installation process is very straightforward, you do not need to manually operate the VirtualBox virtual machine.
  16. During the installation process, it will prompt some messages to you like below.
    Press enter when the Language window is ready.
    
    Press enter when the macOS Utilities window is ready.
    
    Press enter when the Terminal command prompt is ready.
  17. You just need to wait for the virtual machine screen to arrive at each state and then press enter key.
  18. If you meet a virtual machine screen stuck issue during the installation, you can read section 3 of this article.
  19. After the macOS virtual machine is installed successfully, you can run the command ./macos-guest-virtualbox.sh prompt_delete_temporary_files in the macos-guest-virtualbox.sh file saved directory to remove the temporary files.
    $ ./macos-guest-virtualbox.sh prompt_delete_temporary_files
    Can't find VBoxManage in PATH variable,
    checking C:\Program Files\Oracle\VirtualBox\VBoxManage.exe
    Found VBoxManage
    
    The command "VBoxManage list extpacks" either does not list the Oracle VM
    VirtualBox Extension Pack, or lists one or more extensions as unusable.
    The virtual machine will be configured without USB xHCI controllers.
    
    Catalina selected to be downloaded and installed
    
    stage: prompt_delete_temporary_files
    The following temporary files are safe to delete:
    
     ApfsDriverLoader.efi                  Catalina_BaseSystem.chunklist   Catalina_InstallESD.part03   Catalina_InstallInfo.plist         macOS_bootinst.txt                                    macOS_startup.nsh
     AppleImageLoader.efi                  Catalina_BaseSystem.dmg         Catalina_InstallESD.part04   Catalina_bootable_installer.vdi    macOS_configure_nvram.txt                             macOS_system-id.bin
     AppleSupport-v2.0.4-RELEASE.zip       Catalina_BaseSystem.vdi         Catalina_InstallESD.part05   Catalina_installation_files.viso   macOS_csr-active-config.bin
     AppleUiSupport.efi                    Catalina_InstallESD.part00      Catalina_InstallESD.part06   dmg2img.exe                        macOS_populate_bootable_installer_virtual_disk.viso
     Catalina_AppleDiagnostics.chunklist   Catalina_InstallESD.part01      Catalina_InstallESD.part07   macOS_MLB.bin                      macOS_populate_macos_target_disk.viso
     Catalina_AppleDiagnostics.dmg         Catalina_InstallESD.part02      Catalina_InstallESDDmg.pkg   macOS_ROM.bin                      macOS_startosinstall.txt
    
    Delete temporary files listed above? [y/N] y
  20. But I suggest you keep those temporary files for later macOS virtual machine configuration, such as installing the VBox_Guest_Additions, enabling copy & paste, drag & drop, and shared folder between host and guest operating system.
  21. After the macOS VirtualBox virtual machine is installed, you can find the macOS virtual machine is installed under the current user’s home directory such as C:\Users\zhaosong\VirtualBox VMs\macOS. You can move the macOS virtual machine to another disk to save the disk space of the C disk, please refer to the article How To Copy VirtualBox Virtual Machine To Another Computer.

2. How To Install macOS Virtual Machine On Windows VirtualBox Using macos-guest-virtualbox.sh.

  1. On Windows, you need to install the Cygwin to run the macos-guest-virtualbox.sh, you can read the article How To Install Cygwin On Windows Correctly to learn more.
  2. You also need to download the file macos-guest-virtualbox.sh from Github.
  3. In my environment, it is downloaded to the folder C:\Users\zhaosong\Downloads, but I move it to a new folder D:\Work\VirtualBox-VM\MacOS, and it’s mapped Cygwin folder is /cygdrive/d/Work/VirtualBox-VM/MacOS.
    D:\Work\VirtualBox-VM\MacOS,>pwd
    /cygdrive/d/Work/VirtualBox-VM/MacOS
  4. Open the Cygwin terminal and run the command cd /cygdrive/d/Work/VirtualBox-VM/MacOS to go to the script file saved folder.
    $ cd /cygdrive/d/Work/VirtualBox-VM/MacOS
  5. Add execution permission to the file macos-guest-virtualbox.sh with the command chmod +x macos-guest-virtualbox.sh.
    $ chmod +x macos-guest-virtualbox.sh
    
    $ ls -l *.sh
    -rwx--x--x+ 1  85093 Jan  2 13:47 macos-guest-virtualbox.sh
    
  6. Before you can run the script file to install macOS on VirtualBox virtual machine, you need to make sure that you have installed the following Cygwin packages coreutils, bash, gzip, unzip, wget, xxd, tesseract-ocr, tesseract-ocr-eng, you can read section 3. How To Install Additional Cygwin Packages After Install Cygwin of the article How To Install Cygwin On Windows Correctly to learn more.
  7. Now you can run the command Cygwin/mintty in a dos window and go to the script file saved folder.
    C:\cygwin64>Cygwin/mintty
    
    @LAPTOP-9FS71VQM ~
    $
    
    @LAPTOP-9FS71VQM ~
    $ cd /cygdrive/d/Work/VirtualBox-VM/MacOS
    
    @LAPTOP-9FS71VQM /cygdrive/d/Work/VirtualBox-VM/MacOS
    $ ls -l *.sh
    -rwxrwx---+ 1  85093 Mon 2 13:47 macos-guest-virtualbox.sh
  8. Run the script file with command ./macos-guest-virtualbox.sh to start installing the macOS on VirtualBox virtual machine. But you may encounter the below error message.
    The command "VBoxManage list extpacks" either does not list the Oracle VM
    VirtualBox Extension Pack, or lists one or more extensions as unusable.
    The virtual machine will be configured without USB xHCI controllers.
    Locally installing dmg2img
    Error downloading dmg2img. Please provide the package manually.
  9. Dmg2img is a tool that can convert the Apple dmg package file to a standard image disk iso file, you can download it from the URL  http://vu1tur.eu.org/tools/. Or you can also search it from google.
  10. Unzip the downloaded dmg2img zip file to a windows folder, and copy the dmg2img.exe file to the same folder of the macos-guest-virtualbox.sh file.
  11. Now when you run the script file ./macos-guest-virtualbox.sh again, the error will disappear.
  12. Now you can see that a VirtualBox virtual machine has started up, and it will print some text on the screen.

3. How To Fix The Hange Issue When Install macOS On VirtualBox Virtual Machine Use macos-guest-virtualbox.sh.

  1. When the VirtualBox virtual machine starts to install, it may stuck in some stages.
  2. You will find the screen hanging for a long time without going on.
  3. One reason for the screen-hanged issue is that maybe the machine CPU that the VirtualBox supported is not supported by the macOS. You can find this information in the Github readme file CPU Compatibility section.
  4. In my environment, it stuck on the output [EB|#LOG:EXITBS:START] – 2022-01-02T08:00:35.
  5. Open a Cygwin window on Windows or a shell window on Linux, then go to the file macos-guest-virtualbox.sh saved folder and run the command ./macos-guest-virtualbox.sh documentation.
  6. It will show all the help documentation in the console, scroll down to the CPU profiles and CPUID settings (unsupported) section, you can find the supported CPU profile.
            CPU profiles and CPUID settings (unsupported)
    macOS does not support every CPU supported by VirtualBox. If the macOS Base
    System does not boot, try applying different CPU profiles to the virtual
    machine with the VBoxManage commands described below. First, while the
    VM is powered off, set the guest's CPU profile to the host's CPU profile, then
    try to boot the virtual machine:
        VBoxManage modifyvm "${vm_name}" --cpu-profile host
        VBoxManage modifyvm "${vm_name}" --cpuidremoveall
    If booting fails, try assigning each of the preconfigured CPU profiles while
    the VM is powered off with the following command:
        VBoxManage modifyvm "${vm_name}" --cpu-profile "${cpu_profile}"
    Available CPU profiles:
      "Intel Xeon X5482 3.20GHz"  "Intel Core i7-2635QM"  "Intel Core i7-3960X"
      "Intel Core i5-3570"  "Intel Core i7-5600U"  "Intel Core i7-6700K"
    If booting fails after trying each preconfigured CPU profile, the host's CPU
    requires specific macOS VirtualBox CPUID settings.
  7. Now we need to change the macOS virtual machine used CPU profile.
  8. Close the VirtualBox virtual machine window by clicking the close button on the window top right corner.
  9. It will popup a dialog window, choose the Power off the machine radio button to power it off.
  10. Open a Windows dos or Linux terminal window, and go to the VirtualBox installed directory.
  11. And run the command like below, you should try all the CPU profiles listed in the documentation( “Intel Xeon X5482 3.20GHz” “Intel Core i7-2635QM” “Intel Core i7-3960X” “Intel Core i5-3570” “Intel Core i7-5600U” “Intel Core i7-6700K”).
    C:\Program Files\Oracle\VirtualBox>VBoxManage modifyvm "macOS" --cpu-profile host
    
    C:\Program Files\Oracle\VirtualBox>VBoxManage modifyvm "macOS" --cpuidremoveall
    
    C:\Program Files\Oracle\VirtualBox>VBoxManage modifyvm "macOS" --cpu-profile "Intel Core i7-2635QM"
  12. Now click the VirtualBox icon to start the VirtualBox and you can find the macOS virtual machine in the left panel.
  13. Right-click the macOS virtual machine, then click the Start —> Normal Start menu item to start the macOS virtual machine.
  14. Now macOS virtual machine will start as normal and you should wait for the Languages window to appear.
  15. If all the above CPU profiles are not ok for starting the macOS virtual machine, you need special macOS VirtualBox CPU settings.

4. How To Configure The VirtualBox macOS Virtual Machine.

  1. How To Turn On/Off SIP (System Integrity Protection) On Mac OS.
  2. Install the VirtualBox guest additions, you can read the article How To Fix The Error Unable To Insert The Virtual Optical Disk VBoxGuestAdditions.iso Into The Machine.
  3. Adjust the macOS virtual machine’s screen resolution, you can read the article How To Change The Virtualbox Guest macOS Virtual Machine Screen Resolution.
  4. How To Enable Copy Paste ( Shared Clipboard ) Between VirtualBox Host And Guest OS
0 0 votes
Article Rating
Subscribe
Notify of
guest

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

0 Comments
Inline Feedbacks
View all comments
Clicky
0
Would love your thoughts, please comment.x
()
x