Advertisement
Guest User

Untitled

a guest
Nov 3rd, 2018
677
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 8.70 KB | None | 0 0
  1.  
  2. ## macOS Mojave 10.14.1 on VirtualBox without Mac devices, without kext files, and without Clover bootloader
  3. ############################################################################################################
  4.  
  5.  
  6. ## NOT A SCRIPT
  7. ###############
  8.  
  9. ## PLEASE READ, COPY AND PASTE LINES MANUALLY
  10. #############################################
  11.  
  12. ## Requirements:
  13. ## 33.5GB available storage for temporary files (1.5GB) and virtual disk images of base system (2GB), installation (8GB), and target (22GB)
  14.  
  15. ## The following has to be installed manually:
  16. ## VirtualBox
  17. ## dmg2img (from package manager for Linux or http://vu1tur.eu.org/tools/dmg2img-1.6.6-win32.zip for Windows)
  18. ## curl (from package manager for Linux or https://bintray.com/artifact/download/vszakats/generic/curl-7.62.0-win64-mingw.zip for Windows)
  19. ## On Windows: Place dmg2img executable and curl executable and dll in working directory
  20. ## After the first part of the installation, EFI drivers will have to be downloaded manually with Safari
  21.  
  22. ## The following will be downloaded automatically:
  23. ## macOS Mojave 10.14.1 BaseSystem.dmg from Apple - on the host, to bootstrap the VM
  24. ## macOS Mojave 10.14.1 BaseSystem.chunklist InstallInfo.plist AppleDiagnostics.dmg AppleDiagnostics.chunklist BaseSystem.dmg InstallESDDmg.pkg from Apple - on the VM
  25.  
  26. # On the host terminal, create a VirtualBox virtual machine:
  27. vmname="Mojave"
  28. VBoxManage createvm --name "${vmname}" --ostype MacOS_64 --register
  29.  
  30. # Create the macOS base system virtual disk image:
  31. curl 'http://swcdn.apple.com/content/downloads/35/53/091-93471/ff5kp0aiow1d87t494xp5twbugymnlvz16/BaseSystem.dmg' -o BaseSystem.dmg
  32. dmg2img BaseSystem.dmg BaseSystem.img
  33. VBoxManage convertfromraw --format VDI BaseSystem.img BaseSystem.vdi
  34.  
  35. # Create the target virtual disk image:
  36. storagesize=22000    # minimum 22000
  37. VBoxManage createmedium --size="${storagesize}" --filename "${vmname}.vdi" --variant fixed
  38.  
  39. # Create the installation media virtual disk image:
  40. installsize=8000
  41. VBoxManage createmedium --size="${installsize}" --filename "Install ${vmname}.vdi" --variant fixed
  42.  
  43. # Configure the VM
  44. cpucount=4           # minimum 2
  45. memorysize=8192      # minimum 2048
  46. gpuvram=128          # minimum 34
  47. resolution=1280x800
  48. VBoxManage modifyvm "${vmname}" --cpus "${cpucount}" --memory "${memorysize}" --vram "${gpuvram}" --pae on --boot1 dvd --boot2 disk --boot3 none --boot4 none --firmware efi --rtcuseutc on --usbxhci on --chipset ich9 --mouse usb --keyboard usb
  49. VBoxManage storagectl "${vmname}" --add sata --name SATA --hostiocache on
  50. VBoxManage setextradata "${vmname}" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "MacBookPro11,3"
  51. VBoxManage setextradata "${vmname}" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
  52. VBoxManage setextradata "${vmname}" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Mac-2BD1B31983FE1663"
  53. VBoxManage setextradata "${vmname}" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
  54. VBoxManage setextradata "${vmname}" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
  55. VBoxManage setextradata "${vmname}" "VBoxInternal2/EfiGraphicsResolution" "${resolution}"
  56.  
  57. # Attach the target virtual disk image, the EFI drivers, and the base system in the virtual machine:
  58. VBoxManage storageattach "${vmname}" --storagectl SATA --port 0 --type hdd --nonrotational on --medium "${vmname}.vdi"
  59. VBoxManage storageattach "${vmname}" --storagectl SATA --port 1 --type hdd --nonrotational on --medium "Install ${vmname}.vdi"
  60. VBoxManage storageattach "${vmname}" --storagectl SATA --port 2 --type hdd --nonrotational on --medium BaseSystem.vdi
  61.  
  62. # Start the virtual machine. This should take a couple of minutes.
  63. VBoxManage startvm "${vmname}"
  64.  
  65. # Continue on the VM
  66. echo "If this is running as a script, stop."
  67. echo "Download the next part of the instructions from the macOS Terminal:"
  68. read -p "curl http://pastebin.com/raw/ETa8CBv1"
  69. exit
  70.  
  71.  
  72. ## RUN THE FOLLOWING PART ON THE VIRTUAL MACHINE
  73. ################################################
  74. # Start Terminal
  75.  
  76. # Partition the virtual disk images:
  77. vmname="Mojave"
  78. diskutil partitionDisk /dev/disk0 1 GPT APFS "${vmname}" R
  79. diskutil partitionDisk /dev/disk1 1 GPT HFS "Install" R
  80.  
  81. # Download macOS Mojave 10.14.1 installer
  82. urlpath="http://swcdn.apple.com/content/downloads/35/53/091-93471/ff5kp0aiow1d87t494xp5twbugymnlvz16/"
  83. for filename in BaseSystem.chunklist InstallInfo.plist AppleDiagnostics.dmg AppleDiagnostics.chunklist BaseSystem.dmg InstallESDDmg.pkg
  84. do curl "${urlpath}${filename}" -o "/Volumes/${vmname}/${filename}"
  85. done
  86.  
  87. # Create secondary base system
  88. asr restore --source /Volumes/${vmname}/BaseSystem.dmg --target /Volumes/Install
  89.  
  90. # Shut down the virtual machine
  91. shutdown -h now
  92.  
  93.  
  94. ## RUN THE FOLLOWING PART ON THE HOST
  95. #####################################
  96. # Detach the original 2GB BaseSystem.vdi
  97. VBoxManage storageattach "${vmname}" --storagectl SATA --port 2 --medium emptydrive
  98.  
  99. # Start the virtual machine again, this time it will boot from the new 8GB base system
  100. VBoxManage startvm "${vmname}"
  101.  
  102. # Continue on the VM
  103. echo "If this is running as a script, stop."
  104. echo "Download the next part of the instructions from the macOS Terminal:"
  105. read -p "curl http://pastebin.com/raw/Q8GSRRk9"
  106. exit
  107.  
  108.  
  109. ## RUN THE FOLLOWING PART ON THE VIRTUAL MACHINE
  110. ################################################
  111. # Start Terminal
  112. # Make root writable
  113. mount -rw /
  114.  
  115. # Move the installer to the new 8GB base system
  116. vmname="Mojave"
  117. installpath="/Install macOS Mojave.app/Contents/SharedSupport/"
  118. mkdir -p "${installpath}"
  119. cd "/Volumes/${vmname}/"
  120. mv *.chunklist *.plist *.dmg *.pkg "${installpath}"
  121.  
  122. # Rename InstallESDDmg.pkg to InstallESD.dmg and update InstallInfo.plist
  123. mv "${installpath}InstallESDDmg.pkg" "${installpath}InstallESD.dmg"
  124. sed -i.bak -e 's/InstallESDDmg\.pkg/InstallESD.dmg/' -e 's/pkg\.InstallESDDmg/dmg.InstallESD/' "${installpath}InstallInfo.plist"
  125. sed -i.bak2 -e '/InstallESD\.dmg/{n;N;N;N;d;}' "${installpath}InstallInfo.plist"
  126.  
  127. # Start the installer.
  128. # Manually accept the license ("A" and enter).
  129. cd "/Install macOS Mojave.app/Contents/Resources/"
  130. ./startosinstall --volume "/Volumes/${vmname}"
  131.  
  132.  
  133. ## The virtual machine will reboot back into the same base system
  134. #################################################################
  135. # Start Safari (Get Help Online)
  136. # Browse https://github.com/acidanthera/AppleSupportPkg/releases/tag/2.0.4
  137. # Save AppleSupport-v2.0.4-RELEASE.zip on /Volumes/${vmname}/
  138. # (This isn't done with curl because the available version doesn't support https)
  139.  
  140. # Start the Terminal
  141. # Mount the target virtual disk image (empty) EFI partition
  142. vmname="Mojave"
  143. mkdir -p "/Volumes/${vmname}/mount_efi"
  144. mount_msdos /dev/disk0s1 "/Volumes/${vmname}/mount_efi"
  145.  
  146. # Create directory structure
  147. mkdir -p "/Volumes/${vmname}/mount_efi/EFI/driver/"
  148. # Extract and copy drivers
  149. tar -xf "/Volumes/${vmname}/AppleSupport-v2.0.4-RELEASE.zip"
  150. cd "/Volumes/${vmname}/Drivers/"
  151. mv *.efi "/Volumes/${vmname}/mount_efi/EFI/driver/"
  152.  
  153. # Download EFI startup script
  154. cd "/Volumes/${vmname}/mount_efi/"
  155. curl "http://pastebin.com/raw/RkgZRDyd" -o startup.nsh
  156. # The commands can be entered manually in the EFI console if the script is not available
  157. ## echo -off
  158. ## load fs0:\EFI\driver\AppleImageLoader.efi
  159. ## load fs0:\EFI\driver\AppleUiSupport.efi
  160. ## load fs0:\EFI\driver\ApfsDriverLoader.efi
  161. ## map -r
  162. ## fs3:
  163. ## cd "macOS Install Data\Locked Files\Boot Files"
  164. ## boot.efi
  165. ## cd "System\Library\CoreServices"
  166. ## boot.efi
  167.  
  168. # Shut down the virtual machine
  169. shutdown -h now
  170.  
  171.  
  172. ## RUN THE FOLLOWING PART ON THE HOST
  173. #####################################
  174. # Detach the 8GB installation base system
  175. VBoxManage storageattach "${vmname}" --storagectl SATA --port 1 --medium emptydrive
  176.  
  177. # Start the virtual machine again.
  178. # The VM will boot from the target virtual disk image and complete the installation.
  179. VBoxManage startvm "${vmname}"
  180.  
  181.  
  182. ## RUN THE FOLLOWING PART ON THE VIRTUAL MACHINE
  183. ################################################
  184. # macOS Mojave 10.14.1 will start.
  185. # Set up the system and log in.
  186. # Run Terminal and change the EFI startup.nsh script
  187. mkdir -p /tmp/efi
  188. sudo mount_msdos /dev/disk0s1 /tmp/efi
  189. nano /tmp/efi/startup.nsh
  190. # Use the arrow keys to move to the first cd and boot.efi and remove them
  191. # leaving 'cd "System\Library\Coreservices"' and 'boot.efi'
  192.  
  193. ## CLEANUP
  194. ##########
  195. # Shut down the virtual machine
  196. # On the host terminal, erase the temporary files and settings:
  197. VBoxManage list hdds | grep -B4 "Install\|Base"
  198. # "close" the UUID of all unused virtual disk images:
  199. VBoxManage closemedium <UUID-of-BaseSystem.vdi>
  200. VBoxManage closemedium <UUID-of-Install....vdi>
  201. rm BaseSystem.dmn BaseSystem.vdi Install*.vdi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement