Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # This script automatically:
- # finds the recovery partition installed by Apple
- # sets variables to identify it and the parent partition above it
- # erase the recovery partition
- # merge the partition up into its parent
- # Last update June 11th, 2013
- # Free to use and share
- # Just include these lines of code. Copyright© David Koff, 2013
- #----------------------------------------------------------
- # Variables
- #----------------------------------------------------------
- #-----Assignments
- SCRIPTNAME=$0
- #-----Logging
- # use WHATEVER log file suits you best. this is ours.
- exec >> "/Library/Logs/Getty Installations.log" 2>&1 ## must be run as admin or root for exec to work
- #-----Computations
- # establish the drive pattern for the disk(s) in question
- DevRoot=`diskutil list | grep Recovery | cut -c 69-74`
- # isolate the last digit of that partition ID
- DevID=`diskutil list | grep Recovery | cut -c 75`
- # set the variable which contains the FULL drive ID of the recovery partition
- recoveryPart="$DevRoot$DevID"
- echo "The recovery partition we're erasing is: $recoveryPart"
- # we know the main partition is one digit LESS on the chain
- let mergeID=DevID-1
- # set the variable for the drive partition into which we'd like to merge
- mergePart="$DevRoot$mergeID"
- echo "The partition into which we're merging is: $mergePart"
- # find the NAME of the merge partition by setting variable
- mergeName=`diskutil list | grep $mergePart | cut -c 34-57`
- echo "The name of the merge partition is: $mergeName"
- #----------------------------------------------------------
- # Timestamp
- #----------------------------------------------------------
- echo " "
- echo "###################################"
- echo "##### $SCRIPTNAME"
- echo "##### `date "+%A %m/%d/%Y %H:%M"`"
- echo "###################################"
- echo " "
- #----------------------------------------------------------
- # Script
- #----------------------------------------------------------
- echo "The Following Recovery Partition(s) has been found:"
- echo $recoveryPart
- echo ""
- diskutil eraseVolume HFS+ Blank $recoveryPart
- echo ""
- echo "Now merging the space from $recoveryPart into $mergePart"
- diskutil mergePartitions HFS+ $mergeName $mergePart $recoveryPart
- echo ""
- echo "Merging is complete. Recovery Partition has been removed."
- #----------------------------------------------------------
- # Timestamp
- #----------------------------------------------------------
- echo " "
- echo "###################################"
- echo "##### End Log"
- echo "##### `date "+%A %m/%d/%Y %H:%M"`"
- echo "###################################"
- echo " "
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement