Skip to content

Instantly share code, notes, and snippets.

@jamesez
Created January 23, 2013 18:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesez/4611357 to your computer and use it in GitHub Desktop.
Save jamesez/4611357 to your computer and use it in GitHub Desktop.
echo IzzyBoot for Fusion Drives
echo Version 1.0
echo
# Are we already encrypted?
if diskutil cs list | grep "Encrypted Extents" | grep -q "Yes"; then
echo It appears as though this drive is using FileVault2 encryption. This tool is too
echo simple to figure out what to do, but maybe you can use Disk Utility to repartition
echo the drive or remove the encryption first.
echo
exit -1
fi
echo "** WARNING ** This tool is quite simple and makes a number of assumptions."
echo "** WARNING ** Please make sure you have a backup and have removed/unplugged"
echo "** WARNING ** all other storage devices from the Mac before proceeding."
echo
sleep 7
# Already fusion driven?
if diskutil cs list | grep "Index:" | grep -q "1"; then
if diskutil cs info "Macintosh HD" >/dev/null; then
echo It appears this system is already Fusioned, trying to work with that...
fusionDrive=`diskutil cs info "Macintosh HD" | grep "Device Identifier" | awk '{print $3}'`
else
echo "Somehow this system has CoreStorage enabled, but I can't find a logical volume. Giving up."
exit -1
fi
fi
# Skip setting up fusion drive if it's there
if [ "x$fusionDrive" == "x" ]; then
echo "Looking for devices..."
# Determine SSD and Physical drive to use
for disk in `diskutil list | grep dev/disk`; do
if diskutil info $disk | grep -q "SATA" && \
diskutil info $disk | grep "Solid State" | grep -q "Yes" && \
! diskutil info $disk | grep -q "Volume UUID" ; then
devinfo=`diskutil info $disk | grep "Media Name:" | sed 's/.*: *//'`
ssdDevice=$disk
echo " " Solid State Device: $devinfo - $ssdDevice
fi
if diskutil info $disk | grep -q "SATA" && \
diskutil info $disk | grep "Solid State" | grep -q "No" && \
! diskutil info $disk | grep -q "Volume UUID" ; then
devinfo=`diskutil info $disk | grep "Media Name:" | sed 's/.*: *//'`
hardDiskDevice=$disk
echo " " Spinning Drive: $devinfo - $hardDiskDevice
fi
done
if [[ "x$ssdDevice" == "x" || "x$hardDiskDevice" == "x" ]]; then
echo "Can't find both disks; giving up."
exit -2
fi
echo
echo "Repartitioning HDD ($hardDiskDevice) for Recovery HD..."
diskutil partitionDisk $hardDiskDevice 1 GPT jhfs+ "Macintosh HD" 100% > /dev/null
if [ $? != 0 ]; then
echo " ** Failed; giving up here."
exit -3
fi
# Not needed - the image expands into two disks correctly.
# diskutil partitionDisk $hardDiskDevice 2 GPT jhfs+ "Macintosh HD" 100% R jhfs+ "Recovery HD" 650000000B >/dev/null
# echo
# echo "Restoring Recovery HD..."
# asr restore --source https://server/MountainLion-10.8.2-12C2034.recovery.dmg --target ${hardDiskDevice}s3 --erase --noprompt
# diskutil unmount ${hardDiskDevice}s3 >/dev/null
# asr adjust --target ${hardDiskDevice}s3 --settype Apple_Boot
echo
echo "Fusing disks $ssdDevice and $hardDiskDevice into logical volume group..."
lvgUUID=`diskutil cs create "Macintosh HD" ${ssdDevice} ${hardDiskDevice}s2 | grep UUID | sed 's/.*: //'`
if [ $? != 0 ]; then
echo " ** Failed; giving up here."
exit -3
fi
# Wait for disks to become ready
sleep 2
echo
echo "Reticulating splines..."
fusionDrive=`diskutil cs createVolume $lvgUUID jhfs+ "Macintosh HD" 100% | grep 'Core Storage disk:' | sed 's/.*: //'`
echo " FUSED --> $fusionDrive"
fi
echo
echo "Restoring Macintosh HD..."
asr restore --source https://server/MountainLion-10.8.2-12C2034.dmg --target /dev/${fusionDrive} --erase --noprompt
macHD=`diskutil info /dev/${fusionDrive} | grep 'Mount Point' | sed 's/.*: *//'`
bless --folder "$macHD/System/Library/CoreServices" --label "Macintosh HD" --bootefi --setBoot
echo
echo "Configuring Izzy..."
currentAPI=`defaults read /System/Installation/Packages/IzzyBoot.app/Contents/Info IzzyServer | sed 's/\/$//'`
defaults write "$macHD/Library/Preferences/ManagedInstalls.plist" IzzyAPIURL "${currentAPI}/api"
defaults write "$macHD/Library/Preferences/ManagedInstalls.plist" PackageURL "https://server/packages"
defaults write "$macHD/Library/Preferences/ManagedInstalls.plist" SoftwareRepoURL "https://server/repo"
defaults write "$macHD/Library/Preferences/ManagedInstalls.plist" SoftwareUpdateServerURL "http://server/index_stable.sucatalog"
defaults write "$macHD/Library/Preferences/ManagedInstalls.plist" InstallAppleSoftwareUpdates -bool YES
echo "Done. Rebooting in 10 seconds..."
sleep 10
reboot
# done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment