TRIM Enabler for Lion

TRIM Enabler for Lion

Also works for 10.7.1. Note that there is no need to re-patch when applying 10.7.1 as the extension is not replaced during the update.

OK. Now that Lion’s out, people want their SSD TRIM support back. I have one thing to say:

DO NOT USE TRIM ENABLER (VERSION 1.1 OR 1.2) TO ENABLE TRIM ON LION.

After a little inspection of this application, I found that instead of patching the file, it replaces an entire kernel extension. This means that when you use TRIM Enabler with Lion, it replaces a critical kernel extension, with lots of dependencies, with an older one (from Snow Leopard 10.6.8). This is bad. Very bad. While TRIM does become enabled, the kernel extension you now have has the potential to cause a ton of problems. That means anything from kernel panics, to disk I/O delays…and the dreaded spinning beach ball.

After confronting the developer, Oskar Groth (who I refuse to link to), via his blog’s commenting system, I was told that I was simply trolling and spreading fear (even though I offered the alternative I share here). Apparently, the next version of TRIM Enabler will correctly patch the file, instead of replacing it, but that hasn’t happened yet.

So, here’s the proper way to enable TRIM support. Run these commands in Terminal:

1. Backup the file we’re patching

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

2. 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

3. Clear the system kernel extension cache

sudo kextcache -system-prelinked-kernel

sudo kextcache -system-caches

4. Now Reboot!

a) If in the future you want to disable TRIM support

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

sudo kextcache -system-prelinked-kernel

sudo kextcache -system-caches

b) If something goes horribly wrong, restore the backup

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

All this patch does is simply replace the string “APPLE SSD” in the file IOAHCIBlockStorage with zeros. This happens to bypass the restriction of only allowing Apple branded SSDs. The backup of the original file is saved in the same directory as the original file.

To check if it worked, open up About This Mac, click the “More Info…” button then the “System Report” button. In the list on the left, choose “Serial-ATA”. Click on your SSD Drive and in the lower half of the screen you should now see “TRIM Support: Yes” instead of “No”.

Remember, if you have an older generation SSD, the hardware itself may not support TRIM …and therefore this patch won’t help you. This patch bypasses the restriction put in place by Apple to restrict TRIM support to Apple branded SSD drives.

You WILL need to re-apply this patch after each major update of OS X. That means for 10.7.1, 10.7.2, etc.

Credit where credits due, unlike the other TRIM Enabler, I originally found this on theInsanelyMac forums by digital_dreamer

As a note, the MD5 checksums for the original and patched file on 10.7.0 are as follows:

Original: 155b426c856c854e54936339fbc88d72
Modified: 945944136009c9228fffb513ab5bf734

If you have already used the other TRIM Enabler, you can do the following:
a) Attempt to copy and replace the extension from another Mac running the same version.
b) Attempt to copy and replace the extension from the Recovery partition (Open up Disk Utility and Mount Recovery HD)
c) Reinstall Lion
d) Wait it out till 10.7.1 and hope that the extension is replaced in the update (but it may not be), then re-patch the file