Last active
September 9, 2019 20:27
-
-
Save macsimom/9dffb8eaf6ee46bd7a69abc9b7b5b349 to your computer and use it in GitHub Desktop.
Ever minimizing the steps to get Catalina Beta running in VMware Fusion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#### | |
# | |
# Prerequisite steps: | |
# | |
# 1 - Download a copy of the Install macOS app | |
# 2 - Mount the InstallESD.dmg and extract the kernel file with Pacifist from Core.pkg | |
# 3 - Create a new macOS 10.14 vm (give it more ram than the standard 2 GB) | |
# | |
# Run the script "sudo bash macos_vm_kickstarter.sh [full path to Install app] [full path to kernel file] [full path to .vmwarevm bundle]" | |
# Launch the vm and wait for it to boot to recovery then open Terminal in it and type "vmware_guest_install.sh" | |
# | |
##### | |
INSTALLERAPP="$1" | |
KERNELPATH="$2" | |
VMWAREVM="$3" | |
#KERNELPATH="/Users/Shared/Do Not Backup/CatalinaBeta7/kernel" | |
#INSTALLERAPP="/Volumes/Install macOS Catalina Beta/Install macOS Catalina Beta.app" | |
#VMWAREVM="/Users/Shared/Virtual Machines/Catalina.vmwarevm" | |
VMXFILE=$(find "$VMWAREVM" -name \*.vmx -print) | |
# minimal sanity checking | |
if [ ! -e "$KERNELPATH" ]; then echo "Kernel not found"; exit 1; fi | |
if [ ! -d "$INSTALLERAPP" ]; then echo "Installer app not found"; exit 1; fi | |
if [ ! -e "$VMXFILE" ]; then echo "virtual machine not found"; exit 1; fi | |
INSTALLMEDIA="" | |
echo "creating 10 GB install media" | |
hdiutil create -size 10g -fs jhfs+ -volname Installmedia "VMwareInstallmedia" | |
INSTALLMEDIAMOUNT="/Volumes/Installmedia" | |
hdiutil attach VMwareInstallmedia.dmg | |
echo "Restoring Base System to install media" | |
asr restore --source "${INSTALLERAPP}/Contents/SharedSupport/BaseSystem.dmg" --target "$INSTALLMEDIAMOUNT" --erase --noprompt | |
diskutil renameVolume "/Volumes/macOS Base System" Installmedia | |
rm -rf "${INSTALLMEDIAMOUNT}/Install macOS Catalina Beta.app" | |
echo "Copying installer app to install media" | |
cp -pr "${INSTALLERAPP}" "${INSTALLMEDIAMOUNT}/Install macOS Catalina Beta.app" | |
echo "Done" | |
#mv "${INSTALLMEDIAMOUNT}/System/Library/PrelinkedKernels/prelinkedkernel" "${INSTALLMEDIAMOUNT}/System/Library/PrelinkedKernels/prelinkedkernel_apple" | |
rm "${INSTALLMEDIAMOUNT}/System/Library/PrelinkedKernels/prelinkedkernel" | |
echo "Building vmware compatible prelinkedkernel" | |
kextcache -c "${INSTALLMEDIAMOUNT}/System/Library/PrelinkedKernels/prelinkedkernel" \ | |
-K "$KERNELPATH" -z -- \ | |
"${INSTALLMEDIAMOUNT}/System/Library/Extensions" \ | |
"${INSTALLMEDIAMOUNT}/System/Library/Extensions/IOACPIFamily.kext" | |
/usr/libexec/PlistBuddy -c "Set ':Kernel Flags' string -v" "${INSTALLMEDIAMOUNT}/Library/Preferences/SystemConfiguration/com.apple.Boot.plist" | |
bless --folder "${INSTALLMEDIAMOUNT}/System/Library/CoreServices" --file "${INSTALLMEDIAMOUNT}/System/Library/CoreServices/boot.efi" --verbose | |
echo "Writing install script to install media" | |
cat <<EOF > "${INSTALLMEDIAMOUNT}/bin/vmware_guest_install.sh" | |
#!/bin/bash | |
installer -pkg "/Install macOS Catalina Beta.app/Contents/SharedSupport/InstallInfo.plist" \ | |
-target "/Volumes/Macintosh HD" \ | |
-verbose -dumplog | |
rm "/Volumes/Macintosh HD 1/System/Library/PrelinkedKernels/prelinkedkernel" | |
kextcache -c "/Volumes/Macintosh HD 1/System/Library/PrelinkedKernels/prelinkedkernel" \ | |
-K "/Volumes/Macintosh HD 1/System/Library/Kernels/kernel" \ | |
-l -- \ | |
"/Volumes/Macintosh HD 1/System/Library/Extensions" \ | |
"/Volumes/Macintosh HD 1/System/Library/Extensions/IOACPIFamily.kext" | |
bless --folder "/Volumes/Macintosh HD 1/System/Library/CoreServices" \ | |
--file "/Volumes/Macintosh HD 1/System/Library/CoreServices/boot.efi" \ | |
--setBoot --verbose | |
shutdown -r now | |
EOF | |
chmod +x "${INSTALLMEDIAMOUNT}/bin/vmware_guest_install.sh" | |
hdiutil detach "$INSTALLMEDIAMOUNT" | |
INSTALLMEDIABYTES=$(($(stat -f %z VMwareInstallmedia.dmg)/512)) | |
cat <<EOF > "${VMWAREVM}/VMwareInstallmedia.vmdk" | |
# Disk DescriptorFile | |
version=1 | |
encoding="UTF-8" | |
CID=fffffffe | |
parentCID=ffffffff | |
isNativeSnapshot="no" | |
createType="monolithicFlat" | |
# Extent description | |
RW $INSTALLMEDIABYTES FLAT "VMwareInstallmedia.dmg" 0 | |
# The Disk Data Base | |
#DDB | |
ddb.adapterType = "lsilogic" | |
ddb.virtualHWVersion = "6" | |
EOF | |
SATADEVICE=$(($(cat "$VMXFILE" | grep -E '^sata0:' | sed -E 's/sata0:([0-9]+)\..+/\1/'|sort -u | tail -n1)+1)) | |
cat <<EOF >> "$VMXFILE" | |
sata0:${SATADEVICE}.filename = "VMwareInstallmedia.vmdk" | |
sata0:${SATADEVICE}.present = "TRUE" | |
EOF | |
sed -i -E $'s/board-id.*/board-id.reflectHost = "FALSE"\\\nboard-id = "VMWAREGUEST"/' "$VMXFILE" | |
mv "VMwareInstallmedia.dmg" "$VMWAREVM/" | |
chown "$(stat -f %u "$VMXFILE")" "${VMWAREVM}/VMwareInstallmedia.vmdk" "${VMWAREVM}/VMwareInstallmedia.dmg" | |
#open "$VMWAREVM" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for doing this. Worked great, and much easier than making a USB stick and rebooting my physical Mac.