Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ghetto Fusion Drive on Old Macs OS X
#!/bin/bash
# Based on http://jollyjinx.tumblr.com/post/34638496292/fusion-drive-on-older-macs-yes-since-apple-has
# To use this, first create a corestorage drive - see e.g. http://www.cnet.com/how-to/how-to-make-a-custom-corestorage-drive-in-os-x/
# -- it'll look something like this:
#
# diskutil list # and figure out which actual drives you want to join
# diskutil cs create FusionGroup disk0 disk2 # or whichever two drives
# diskutil cs list # and note the Logical Volume Group ID
# diskutil cs createVolume GROUPID jhfs+ Fused 100%
#
# Then to make sure it's working like a Fusion (and not just a conjoined virtual drive),
# run this script in one Terminal window (assuming you named your new drive Fused):
# ./fusion_test.sh /Volumes/Fused
#
# In another Terminal window, run iostat:
# iostat -d 1
#
# During the first phase, you should see writes on your SSD until about dir 12,
# then it should switch to your HDD.
#
# When the script asks you to hit return, wait until activity dies down.
# During the second phase, we continually read the files that were originally written to HDD.
# Reads should happen from the HDD for a while. Wait for a few loops.
# Then hit control-Z to pause this script and watch the iostat window.
# If Fusion is really working, then you should see activity on both drives
# as CS shuffles the files between HDD and SSD for a few minutes (maybe 10).
# Then type "fg" to resume this script.
#
# Watch and repeat a few times.
# Eventually all reads should happen from SSD.
#
# When you quit this script with control-C, it will delete all the temporary files.
# I used Mavericks and two external drives -- a Thunderbolt SSD and a USB 3.0 HDD -- and Fusion appeared to work okay.
# We create directories 00 to 13 with 100 files each 100 Mbytes in size
# -- about 140G. (If your SSD is 256G then change 13 to 25)
if [[ -z "$1" ]]; then
echo "Usage: fusion_test.sh dir"
exit 1
fi
mdutil -i off $1 # turn off Spotlight indexing on the volume
written="0"
base="$1/bogus"
mkdir -p "$base"
function clean_up {
echo
echo Exiting...
rm -r "$base"
exit
}
trap clean_up SIGINT
for d in {00..13}; do
mkdir -p "$base/$d"
for f in {00..99}; do
mkfile 100m "$base/$d/$f"
written=`expr $written + 100`
echo -ne "Wrote ${written}m\r"
done
done
echo
echo -n "Press return to start reading>"
read
echo -ne "Reading "
while `true`; do
for d in {12..13}; do
for f in $base/$d/*; do
echo -ne "Reading $f \\033[0K\r" # clear to eol, then cr
dd if=$f of=/dev/null bs=1m 2>/dev/null
done
done
done
You can’t perform that action at this time.