Trim Support: The OS X Malfunction

For those of you who are using Apple branded SSD's in your Mac's, this post may not be useful. One week ago, I decided to pony up the cash and give my 2010 Macbook Pro (i7) a speed boost. I picked up an OCZ Agility 120GB SSD (via slickdeals) for ~$130 after rebate. A couple days later, I received the drive and installed it in place of my existing CD-ROM drive. I installed OS X and within ~10 minutes I was using my Mac with the SSD.

To my disappointment, I noticed TRIM support was not being recognized by OS X despite my drive fully supporting the technology. After searching online, I discovered that OS X 10.7 does not support TRIM on non-Apple branded SSD's. This was quite disappointing, so per usual, I continued my search to find hack to enable. I found two options, one being a piece of software called TRIM enabler, and the other being a few terminal commands that modifies the list of SSD's that OS X is willing to support.

I was skeptical regarding TRIM enabler software and upon further research, I would highly recommend NOT using it. TRIM enabler replaces the 10.7 disk kernel with the kernel from 10.6.8. Therefore, I went ahead and used the terminal commands (which I will include below), and now I have a non-Apple SSD with TRIM enabled. I wanted to share my experience with the Verge forums. Cheers!

-M

Via GDGT:

So, here's the proper way to enable TRIM support. Copy these commands out, find/delete all "[REMOVE ME]" placeholders so the commands are contiguous, and run them in Terminal:

→ Backup the file we're patching:

sudo cp /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage /IOAHCIBlockStorage.original

→ Patch the file to enable TRIM support:

sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00).{9}(\x00\x51)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage

→ Clear the kext caches

sudo kextcache -system-prelinked-kernel

sudo kextcache -system-caches

→ Now, Reboot!

→ If in the future you want to disable TRIM support:

sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61[REMOVE ME]\x6C\x00).{9}(\x00\x51)|$1\x41\x50\x50\[REMOVE ME]x4C\x45\x20\x53\x53\x44$2|sg' /System/Library/Extensions/IOAHCIFamily.[REMOVE ME]kext/Contents/PlugIns/IOAHCIBlockStorage[REMOVE ME].kext/Contents/MacOS/IOAHCIBlockStorage

→ Or if something goes horribly wrong, restore the backup:

sudo cp /IOAHCIBlockStorage.original /System/Library/Extensions/IOAHCIFamily.[REMOVE ME]kext/Contents/PlugIns/IOAHCIBlockStorage[REMOVE ME].kext/Contents/MacOS/IOAHCIBlockStorage

All the patch does is edit the IOAHCIBlockStoage file, patching out the string "APPLE SSD" to zeros. This happens to enable TRIM support for all SSDs.