Skip to content

Instantly share code, notes, and snippets.

@vishvish
Forked from jonathantneal/recovery.sh
Created July 21, 2019 19:02
Show Gist options
  • Select an option

  • Save vishvish/af142184d23d6916e8e526c8b431f747 to your computer and use it in GitHub Desktop.

Select an option

Save vishvish/af142184d23d6916e8e526c8b431f747 to your computer and use it in GitHub Desktop.

Revisions

  1. @jonathantneal jonathantneal revised this gist Apr 8, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion recovery.sh
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ echo "Target disk is \"$TARGET\""
    FS_TYPE=$(diskutil info "$TARGET" | awk '$1 == "Type" { print $NF }')
    echo "Target filesystem is \"${FS_TYPE}\""

    # Download the APFS-compatible into /private/tmp
    # Download the APFS-compatible Recovery into /private/tmp (use 10.13.6, which also works with Mojave 10.14.x)
    echo "Downloading macOSUpd10.13.6.RecoveryHDUpdate.pkg into /private/tmp"
    curl http://swcdn.apple.com/content/downloads/42/58/091-94330/mm8vnigq4ulozt9iqhgcl9hp8m7iygsqbl/macOSUpd10.13.6.RecoveryHDUpdate.pkg --progress-bar -L -o /private/tmp/macOSUpd10.13.6.RecoveryHDUpdate.pkg
    pkgutil --expand /private/tmp/macOSUpd10.13.6.RecoveryHDUpdate.pkg /private/tmp/recoveryupdate10.13.6
  2. @jonathantneal jonathantneal created this gist Oct 13, 2018.
    29 changes: 29 additions & 0 deletions recovery.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    #!/bin/sh

    # Set the macOS installer path as a variable
    MACOS_INSTALLER="/Applications/$(ls /Applications | grep "Install macOS")"
    MOUNT_POINT="$MACOS_INSTALLER/Contents/SharedSupport"
    echo "macOS installer is \"$MACOS_INSTALLER\""

    # Set the target disk as a variable
    TARGET=$(diskutil info "$(bless --info --getBoot)" | awk -F':' '/Volume Name/ { print $2 }' | sed -e 's/^[[:space:]]*//')
    echo "Target disk is \"$TARGET\""

    # Set the target disk filesystem
    FS_TYPE=$(diskutil info "$TARGET" | awk '$1 == "Type" { print $NF }')
    echo "Target filesystem is \"${FS_TYPE}\""

    # Download the APFS-compatible into /private/tmp
    echo "Downloading macOSUpd10.13.6.RecoveryHDUpdate.pkg into /private/tmp"
    curl http://swcdn.apple.com/content/downloads/42/58/091-94330/mm8vnigq4ulozt9iqhgcl9hp8m7iygsqbl/macOSUpd10.13.6.RecoveryHDUpdate.pkg --progress-bar -L -o /private/tmp/macOSUpd10.13.6.RecoveryHDUpdate.pkg
    pkgutil --expand /private/tmp/macOSUpd10.13.6.RecoveryHDUpdate.pkg /private/tmp/recoveryupdate10.13.6

    if [[ "${FS_TYPE}" == "apfs" ]]; then
    echo "Running ensureRecoveryBooter for APFS target volume: $TARGET"
    /private/tmp/recoveryupdate10.13.6/Scripts/Tools/dm ensureRecoveryBooter "$TARGET" -base "$MOUNT_POINT/BaseSystem.dmg" "$MOUNT_POINT/BaseSystem.chunklist" -diag "$MOUNT_POINT/AppleDiagnostics.dmg" "$MOUNT_POINT/AppleDiagnostics.chunklist" -diagmachineblacklist 0 -installbootfromtarget 0 -slurpappleboot 0 -delappleboot 0 -addkernelcoredump 0
    else
    echo "Running ensureRecoveryPartition for Non-APFS target volume: $TARGET"
    /private/tmp/recoveryupdate10.13.6/Scripts/Tools/dm ensureRecoveryPartition "$TARGET" "$MOUNT_POINT/BaseSystem.dmg" "$MOUNT_POINT/BaseSystem.chunklist" "$MOUNT_POINT/AppleDiagnostics.dmg" "$MOUNT_POINT/AppleDiagnostics.chunklist" 0 0 0
    fi

    echo "Finished creating Recovery HD"