References:
https://raw.githubusercontent.com/munki/macadmin-scripts/master/installinstallmacos.py
https://github.com/AlexanderWillner/runMacOSinVirtualBox
Required Software:
The following software is needed.
- macOS Installer (Install from AppStore)
- VirtualBox (https://www.virtualbox.org/)
- VirtualBox Extension Pack (note: released under the Personal Use and Evaluation License)(https://download.virtualbox.org/virtualbox/6.0.6/Oracle_VM_VirtualBox_Extension_Pack-6.0.6.vbox-extpack) Tools–>Preferences–>Extensions–>Add the vbox-extpack you downloaded, or use brew command “brew cask install virtualbox-extension-pack” to install it.
Step by Step:
Execute make all
to setup and run everything. After the installer reboots, press enter in the terminal to finish the installation.
$ make all
Running checks (around 1 second)....
Creating image '/Users/awi/VirtualBox VMs/macOS-Mojave.dmg' (around 20 seconds, version 14.2.2, will need sudo)....
Creating iso '/Users/awi/VirtualBox VMs/macOS-Mojave.iso.cdr' (around 25 seconds)....
Creating VM HDD '/Users/awi/VirtualBox VMs/macOS-Mojave/macOS-Mojave.vdi' (around 5 seconds)....
Creating VM 'macOS-Mojave' (around 2 seconds)....
Adding APFS drivers to EFI in '/Users/awi/VirtualBox VMs/macOS-Mojave/macOS-Mojave.vdi' (around 5 seconds)....
Starting VM 'macOS-Mojave' (3 minutes in the VM)....
Press enter to stop VM 'macOS-Mojave' (e.g. after installer restarted)....
Ejecting installer DVD for VM 'macOS-Mojave'....
Starting VM 'macOS-Mojave' (3 minutes in the VM)....
Customizing your build
Additionally the following parameters can be customized with environment variables:
variable name | description | default value |
---|---|---|
VM_NAME | name of the virtual machine | macOS-Mojave |
VM_DIR | directory, where the virtual machine will be stored | HOME/VirtualBox VMs/$VM_NAME |
VM_SIZE | the size of the hard disk | 32768 |
VM_RES | monitor resolution | 1680×1050 |
VM_RAM | ram size in megabytes | 4096 |
VM_VRAM | video ram size in megabytes | 128 |
VM_CPU | number of cpu cores to allocate | 2 |
Execute make
to get some help:
$ make
Some available commands:
* all : run everything needed (check, installer, vm, patch, run, stop, eject)
* check : check environment
* installer: create macOS installer image
* clover : create clover boot image
* patch : add APFS drivers to VM EFI to boot w/o clover
* vm : create VM and disk
* run : run VM
* stop : stop VM
* wait : wait for VM to stop
* eject : eject installer medium
* clean : delete generated images and downloaded files
* stash : delete generated VM and disk
* test : test shell scripts
* style : style shell scripts
* harden : harden shell scripts
* release : make new release
* feedback : create a GitHub issue
Install Mojave installer:
You could install mojave installer from Appstore,or use the install script “installinstallmacos.py” for another way.
Download:
curl -O https://raw.githubusercontent.com/munki/macadmin-scripts/master/installinstallmacos.py
Install python depends:
yuanjideMacBook-Air:MacOS_On_Virtualbox yuanjizhao$ pip3 install xattr
Collecting xattr
Downloading https://files.pythonhosted.org/packages/fa/3b/e8f831c31fcfc01edf430185f99ce1edd23b5bbce5bc7dc8ce52b2565121/xattr-0.9.6-cp37-cp37m-macosx_10_12_x86_64.whl
Requirement already satisfied: cffi>=1.0.0 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from xattr) (1.12.2)
Requirement already satisfied: pycparser in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from cffi>=1.0.0->xattr) (2.19)
Installing collected packages: xattr
Successfully installed xattr-0.9.6
Run the script:
yuanjideMacBook-Air:MacOS_On_Virtualbox yuanjizhao$ python3 installinstallmacos.py
This command requires root (to install packages), so please run again with sudo or as root.
yuanjideMacBook-Air:MacOS_On_Virtualbox yuanjizhao$ sudo python3 installinstallmacos.py
installinstallmacos.py:96: DeprecationWarning: The readPlist function is deprecated, use load() instead
seed_catalogs = plistlib.readPlist(SEED_CATALOGS_PLIST)
Downloading https://swscan.apple.com/content/catalogs/others/index-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog...
installinstallmacos.py:334: DeprecationWarning: The readPlist function is deprecated, use load() instead
catalog = plistlib.readPlist(localcatalogpath)
Downloading http://swcdn.apple.com/content/downloads/12/40/091-95155/piv8296jbzadg8qb5m3gatbllz60d2flsw/InstallAssistantAuto.smd...
installinstallmacos.py:242: DeprecationWarning: The readPlist function is deprecated, use load() instead
md_plist = plistlib.readPlist(filename)
Downloading https://swdist.apple.com/content/downloads/12/40/091-95155/piv8296jbzadg8qb5m3gatbllz60d2flsw/091-95155.English.dist...
Downloading http://swcdn.apple.com/content/downloads/44/42/041-47723/gt7p2zncc41nrdr8ahp0c4udjrf01r43kn/InstallAssistantAuto.smd...
Downloading https://swdist.apple.com/content/downloads/44/42/041-47723/gt7p2zncc41nrdr8ahp0c4udjrf01r43kn/041-47723.English.dist...
Downloading http://swcdn.apple.com/content/downloads/32/45/041-56507/k6okp4vkzucqpoxrgrgycji6jo8z8na8sg/InstallAssistantAuto.smd...
Downloading https://swdist.apple.com/content/downloads/32/45/041-56507/k6okp4vkzucqpoxrgrgycji6jo8z8na8sg/041-56507.English.dist...
# ProductID Version Build Post Date Title
1 091-95155 10.13.6 17G66 2019-01-08 macOS High Sierra
2 041-47723 10.14.4 18E2034 2019-03-25 macOS Mojave
3 041-56507 10.14.4 18E227 2019-04-18 macOS Mojave
Choose a product to download (1-3): 3
Downloading http://swcdn.apple.com/content/downloads/32/45/041-56507/k6okp4vkzucqpoxrgrgycji6jo8z8na8sg/InstallAssistantAuto.pkg...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 11.0M 100 11.0M 0 0 5493k 0 0:00:02 0:00:02 --:--:-- 5756k
Downloading https://swdist.apple.com/content/downloads/32/45/041-56507/k6okp4vkzucqpoxrgrgycji6jo8z8na8sg/InstallAssistantAuto.pkm...
Downloading http://swcdn.apple.com/content/downloads/32/45/041-56507/k6okp4vkzucqpoxrgrgycji6jo8z8na8sg/BaseSystem.dmg...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
90 467M 90 424M 0 0 6114k 0 0:01:18 0:01:11 0:00:07 5133k
100 467M 100 467M 0 0 6047k 0 0:01:19 0:01:19 --:--:-- 5230k
Downloading http://swcdn.apple.com/content/downloads/32/45/041-56507/k6okp4vkzucqpoxrgrgycji6jo8z8na8sg/RecoveryHDMetaDmg.pkg...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 468M 100 468M 0 0 5785k 0 0:01:22 0:01:22 --:--:-- 5999k
Downloading https://swdist.apple.com/content/downloads/32/45/041-56507/k6okp4vkzucqpoxrgrgycji6jo8z8na8sg/RecoveryHDMetaDmg.pkm...
Downloading http://swcdn.apple.com/content/downloads/32/45/041-56507/k6okp4vkzucqpoxrgrgycji6jo8z8na8sg/InstallESDDmg.pkg
Convert cdr to iso format:
hdiutil convert /path/imagefile.cdr -format UDTO -o /path/convertedimage.iso
Suggestion:
We have good method to setup Mojave virtual machine On MacOS
First:install a macos virtual machine on paralells desktop,
Second:Import the it to Vmware Fusion.
Reference:how to convert a Parallels Virtual Machine to a VirtualBox Virtual Machine