Just recently, Apple started supporting TRIM in OS X Lion 10.7 Beta 1 build and also for Apple SSD’s in the new 2011 MacBook Pro’s with Snow Leopard 10.6.6 pre-loaded.

I came across this forum post on HardMac describing how to enable TRIM on third party SSD’s.

I followed the instructions and was able to get TRIM enabled for my 160GB Intel X25-M G2 SSD on my 2010 MacBook Pro. The post, however, is hard to follow, so I’ll do my best to explain how to enable TRIM on your own SSD.

WARNING: YOU ARE EDITING SYSTEM FILES. I AM NOT RESPONSIBLE IF YOUR SYSTEM IS DAMAGED DURING THIS PROCESS. PLEASE DO NOT ATTEMPT THIS IF YOU ARE NOT COMPUTER/MAC SAVVY.

Screen shot 2011 03 25 at 2 53 39 PMStep One — Get your info right:

  1. Make sure the SSD you want to use supports TRIM (A simple Google search will help you find out).
  2. Find out what name of your SSD is by opening “System Profiler” (hold option while clicking on the apple menubar icon to access it).
  3. Once in System Profiler, click on the “Serial-ATA” tab under Contents.
  4. You will see something similar to “Intel 5 Series Chipset”
  5. Below that you will find the name of your SSD. My SSD was named “INTEL SSDSA2M160G2GC”.
  6. Copy the first 9 characters of your SSD name. Mine was “INTEL SSD”.

Step Two — Get your files in order:

  1. Download the hex editor OxED or any other hex editor you prefer.
  2. Download and extract the IOAHCIFamily.kext extension zip file here: http://d.pr/QAE6 (This comes with the new 2011 MacBook Pro’s)
  3. Right-click on “IOAHCIFamily.kext” and click on “Show Package Contents”.
  4. Open on the “Contents” folder and then open on the “Plugins” folder.
  5. You will see two files, “IOAHCIBlockStorage.kext” and “IOAHCISerialATAPI.kext”.
  6. Right-click on “IOAHCIBlockStorage.kext” and click on “Show Package Contents”
  7. Open on the “Contents” folder and then open the “MacOS” folder. Leave the folder open.

Step Three — Make your Backup:

  1. Make a backup of your “IOAHCIFamily.kext” file in System/Library/Extensions by copying it to another location on your computer just in case you mess things up.

Step Four — Modify the file:

  1. Launch the hex editor you downloaded and select “File–> Open” from the menubar.
  2. Drag and drop the “IOAHCIBlockStorage” file from the “MacOS” folder you left open into the open window.
  3. Search for the following characters in the file: “APPLE SSD” by using “CMD-F” on your keyboard to prompt the find window.
  4. Find “APPLE SSD” and replace those nine characters with “INTEL SSD” or whatever your SSD is named in System Profiler (You found this information in Step One — Get your info right). This will show that you found and replaced two items.
  5. Save the file (CMD-S) and quit the editor.

Step Five — Replace the file:

  1. Take the kext file you modified (“IOAHCIFamily.kext”) and replace the same file in System/Library/Extensions. You will need your administrator password to authenticate it.

Step Six — Fix Permissions:

  1. Go to the System/Library folder and select the Extensions folder. Press CMD-I on your keyboard to bring up the info pane. Click on the lock and authenticate your user.
  2. Click on the gear icon and select “apply to all enclosed items…” and approve the change.
  3. Open Disk Utility, find your SSD partition, and “Repair Disk Permissions”.

Step Seven — Restart:

  1. Reboot your mac.

Step Eight — If things messed up and you got a circle crossed out during boot up:

  1. Manually turn off your computer by holding the power button.
  2. Press the power button while holding down “shift” until the boot is complete. This will boot your Mac without any extensions.
  3. Restart your computer.

If you did everything exactly as I said, you should be golden and now have TRIM enabled on your SSD on your Mac! Let me know how it turns out for you. My twitter account is @rafeed. Feel free to ask any questions there.

Update 1: I ran some benchmarks with XBench and here are some results I got.

When SSD was first installed on Mac: Disk Test 318.14 Sequential 207.75 Uncached Write 170.59 104.74 MB/sec [4K blocks] Uncached Write 174.13 98.52 MB/sec [256K blocks] Uncached Read 193.62 56.66 MB/sec [4K blocks] Uncached Read 402.53 202.31 MB/sec [256K blocks]

Random 678.85 Uncached Write 769.54 81.46 MB/sec [4K blocks] Uncached Write 317.76 101.73 MB/sec [256K blocks] Uncached Read 2472.55 17.52 MB/sec [4K blocks] Uncached Read 960.24 178.18 MB/sec [256K blocks]

After several months of usage: Disk Test 238.82 Sequential 214.17 Uncached Write 177.97 109.27 MB/sec [4K blocks] Uncached Write 177.01 100.15 MB/sec [256K blocks] Uncached Read 197.77 57.88 MB/sec [4K blocks] Uncached Read 425.14 213.67 MB/sec [256K blocks]

Random 269.88 Uncached Write 224.02 23.72 MB/sec [4K blocks] Uncached Write 112.51 36.02 MB/sec [256K blocks] Uncached Read 2531.80 17.94 MB/sec [4K blocks] Uncached Read 930.71 172.70 MB/sec [256K blocks]

After putting in TRIM: Disk Test 312.17 Sequential 204.24 Uncached Write 179.39 110.14 MB/sec [4K blocks] Uncached Write 174.82 98.91 MB/sec [256K blocks] Uncached Read 171.96 50.32 MB/sec [4K blocks] Uncached Read 404.14 203.12 MB/sec [256K blocks]

Random 662.01 Uncached Write 747.48 79.13 MB/sec [4K blocks] Uncached Write 307.93 98.58 MB/sec [256K blocks] Uncached Read 2330.89 16.52 MB/sec [4K blocks] Uncached Read 972.88 180.52 MB/sec [256K blocks]

Update 2: I found a little app that can do this for you if you’re not too sure about modifying the file yourself. TRIMEnabler

Update 3: From xlr8yourmac 1) Apple can do it (just show “yes”) through detecting media type of Disk in System Profiler (which is more simple) instead of using for this AHCI driver. And another thing — this is all SSDs, just with different names, which all supports unified commands.

2) IOAHCIBlockStorage.kext is not something simple. This driver (Input Output Advanced Host Controller Interface Block Storage) manages all IO for SATA Storage Devices, ie. NCQ, R/W operations, TRIM, etc.. How OS checks that TRIM is supported and works in drive? As you can see in my last message — we tested a group of disks, the ones which support TRIM natively and those which produced early that lacked TRIM support. Those disk that supported it, OS recognized. Those which lacked it OS shows “TRIM Support: No” without exception. To check — IOAHCI after detecting that this is not “rotational” disk (reports no spinning speed), it sends the TRIM commands “BuildATATrimCommand” (found inside IOAHCIBlockStoorage) to the SSD. If SSD executes this, on specific address of clusters after trimming will be zeroes like if we had a secure format with zeroes, then IOAHCI reports that command executed, and SSD supports TRIMming. If the command was ignored and not executed, OS reports that this SSD doesn’t support TRIM. This command is not a process which can be monitored by Activity Monitor. It is just a command to SSD’s controller which will do this work fully automatically without OS intrusion. This is the algorithm to understand “how os checks that TRIM is supported and executed”.

3) Another proof. First what we noted is reverting performance via synthetic test back to original. Another — is using “hdparm” method. Booted in linux, mount SSD with HFS, creates small file in specific place and saves the info about address of sectors that contains that file. In linux TRIM is turned off for HFS. Boot to OS X and delete this file. Back to linux — check the address — and we see only zeros. TRIM is working.