Advertisement
themacdweeb

RemoveAppleRecoveryPartition.sh

Jun 14th, 2013
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.76 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # This script automatically:
  4. #    finds the recovery partition installed by Apple
  5. #    sets variables to identify it and the parent partition above it
  6. #    erase the recovery partition
  7. #    merge the partition up into its parent
  8.  
  9. # Last update June 11th, 2013
  10.  
  11. # Free to use and share
  12. # Just include these lines of code. Copyright© David Koff, 2013
  13.  
  14. #----------------------------------------------------------
  15. #   Variables
  16. #----------------------------------------------------------
  17.  
  18. #-----Assignments
  19. SCRIPTNAME=$0
  20.  
  21. #-----Logging
  22. # use WHATEVER log file suits you best. this is ours.
  23. exec >> "/Library/Logs/Getty Installations.log" 2>&1  ## must be run as admin or root for exec to work
  24.  
  25. #-----Computations
  26. # establish the drive pattern for the disk(s) in question
  27. DevRoot=`diskutil list | grep Recovery | cut -c 69-74`
  28.  
  29. # isolate the last digit of that partition ID
  30. DevID=`diskutil list | grep Recovery | cut -c 75`
  31.  
  32. # set the variable which contains the FULL drive ID of the recovery partition
  33. recoveryPart="$DevRoot$DevID"
  34. echo "The recovery partition we're erasing is: $recoveryPart"
  35.  
  36. # we know the main partition is one digit LESS on the chain
  37. let mergeID=DevID-1
  38.  
  39. # set the variable for the drive partition into which we'd like to merge
  40. mergePart="$DevRoot$mergeID"
  41. echo "The partition into which we're merging is: $mergePart"
  42.  
  43. # find the NAME of the merge partition by setting variable
  44. mergeName=`diskutil list | grep $mergePart | cut -c 34-57`
  45. echo "The name of the merge partition is: $mergeName"
  46.  
  47. #----------------------------------------------------------
  48. #  Timestamp
  49. #----------------------------------------------------------
  50. echo "                                   "
  51. echo "###################################"
  52. echo "##### $SCRIPTNAME"
  53. echo "##### `date "+%A %m/%d/%Y %H:%M"`"
  54. echo "###################################"
  55. echo "                                   "
  56.  
  57. #----------------------------------------------------------
  58. #  Script
  59. #----------------------------------------------------------
  60. echo "The Following Recovery Partition(s) has been found:"
  61. echo $recoveryPart
  62. echo ""
  63.  
  64. diskutil eraseVolume HFS+ Blank $recoveryPart
  65. echo ""
  66.  
  67. echo "Now merging the space from $recoveryPart into $mergePart"
  68. diskutil mergePartitions HFS+ $mergeName $mergePart $recoveryPart
  69. echo ""
  70.  
  71. echo "Merging is complete. Recovery Partition has been removed."
  72.  
  73. #----------------------------------------------------------
  74. #  Timestamp
  75. #----------------------------------------------------------
  76. echo "                                   "
  77. echo "###################################"
  78. echo "##### End Log"
  79. echo "##### `date "+%A %m/%d/%Y %H:%M"`"
  80. echo "###################################"
  81. echo "                                   "
  82.  
  83. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement