Question about
ryan

In OS X Lion how do you enable TRIM support for SSDs?

One of the things Lion (and a few select late builds of Snow Leopard) unofficially-officially supports is TRIM for SSDs -- a highly necessary command that keeps the flash memory in your SSD properly cycled, resulting in faster reads, writes, and greater longevity for the device.

Right now Apple's TRIM support seems to be limited only to Apple SSDs, though. I am running an Intel X-25M (G2, or second-gen) SSD in my MacBook Pro, and this SSD does support TRIM, however there's no apparent way to enable it in Lion. Anyone have pointers on this?

See also: www.macrumors.com­/2011­/06­/27­/mac­-os­-x­-10­-6­-8­-bring...
top answers
ryan's pick
DigitalDJ

Don't use TRIM Enabler, it's bad software! It replaces a Lion kernel extension with one from 10.6.8! You should revert the change ASAP. Using an older extension is only going to cause problems and conflicts with dependent extensions. I called the developer out about this problem and he claims that he's going to update TRIM enabler to simply patch, instead of replace, but he hasn't yet...and he deleted my comment :P

Instead, you can run the following Terminal commands:

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.[REMOVE ME]kext/Contents/PlugIns/IOAHCIBlockStorage[REMOVE ME].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[REMOVE ME]\x6C\x00).{9}(\x00\x51)|$1\x00\x00\x00\[REMOVE ME]x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.[REMOVE ME]kext/Contents/PlugIns/IOAHCIBlockStorage[REMOVE ME].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.

Please visit my post about these Terminal commands here: digitaldj.net­/2011­/07­/21­/trim­-enabler­-for­-lion/
mark as good answer

43 people like this answer

Clicking the mark as good answer button helps us highlight the best answers.

community pick
ryan

Right after I posted this I spotted that third-party TRIM enabler app that started floating around a couple of weeks ago:
groths.org­/­?p­=308
groths.org­/zeus­/TRIMEnabler.zip

I have NOT tested this, and have no idea if it's going to blow anything up in Snow Leopard, Lion, or otherwise.

Lifehacker also wrote a pretty good looking guide here: lifehacker.com­/5803331­/how­-to­-enable­-trim­-on­-your­-...

Has anyone had any luck with it thus far?
mark as good answer

4 people like this answer

sort by

10 more answers
tdskate

I've used Trim Enabler on my 10.6.8 before upgrading to Lion. Then after the upgrade, Trim was disabled again, so yesterday I used the latest Trim Enabler (1.2 for version 10.6.8) and now Trim is enabled on Lion...

I foolishly forgot to make a back up with the Trim Enabler app and now after reading this, I'm starting to get worried. What should I do?

Capacity: 180,05 GB (180.045.766.656 bytes)
Model: OCZ-VERTEX2
Revision: 1,280000
...
TRIM Support: Yes
mark as good answer

2 people like this answer

sarge

Trim Enabler is a great little utility that will enable it:

www.groths.org­/­?p­=308
mark as good answer

1 person likes this answer

shortie

I used Trim Enabler app on my 10.6 and upgraded to Lion in the Dev program with the GM version around 14 days ago. I have had no issues in regards to trim support.
mark as good answer

0 people like this answer

treks

DigitalDJ's command worked fine for me, but it didn't enable the trim. i use SSDSA2M160G2GC (same drive as Ryan, i believe). in system info:

INTEL SSDSA2M160G2GC:

Capacity: 160.04 GB (160,041,885,696 bytes)
Model: INTEL SSDSA2M160G2GC
Revision: 2CV102HD
...
TRIM Support: No
...

maybe some caching is involved?
mark as good answer

0 people like this answer

YYS

Gave DigitalDJ's solution a go and it worked beautifully. Go checkout his website.

Cheers,
mark as good answer

0 people like this answer

rav3n

I've ran the trim enabler on 10.6.8 with and it worked fine on my mid 2009 macbook pro with Crucial Real-SSD, just upgraded to Lion and run it again (the upgrade removed the hack) and its worked fine, no issues so far
mark as good answer

0 people like this answer

tobiasg

I have the Apple SSD drive that came with my new laptop - do I need to do anything? I can't seem to find anything that says Trim on or off anywhere in disk info. I appreciate if someone could point me in the right direction.
mark as good answer

0 people like this answer

JDThird

I just used his instructions above with a Crucial SATA3 256GB drive in Lion on my 2011 MBP, had not had trim enabled when I was using snow leopard, so first try, and it shows enabled now, no issues at all. Thanks!
mark as good answer

0 people like this answer

iMars

My SSD (INTEL SSDSA2BW160G3H) won't work with this code you've given
-bash: syntax error near unexpected token `.{9}'
mark as good answer

0 people like this answer

WiseMax

Hello. I have followed this discussion with great interest.
The reason? Got an OCX Agility 3 (480 GB) that worked fine in a Windows machine, then got another 240 GB one (same brand & type) and replaced, so that I could use the bigger one on my Macbook Pro (Late 2008, last one with removable battery, I think, 15" screen, Processor 2,8 GHz Intel Core 2 Duo, 4 GB RAM, NVidia chipset & screen adapter - 9600).

Ok, here is the story.

Right after I installed a fresh copy of Lion (used the USD stick method, works nice) I checked and there ws no TRIM enable in the System Info. After a quick Googlation, I found you guys.

The script method to patch the kext works... well, sort of.

I guess I am one of those people that repeated the same process that Apple went through! The trouble is, I believe, in the NVidia MCP79 AHCI controller.

Symptoms? Machine overheating and commanding me to shut down with the power button after intense disk activity (I was restoring the Bootcamp partition with Winclone, happened twice). I had also noticed some heating on the SSD unit, but really I wouldn't know what would be right, since it was being heavily used at the moment.

Also, lots of stuttering and brief freezing in applications (example: Safari...)

I don't know if t is the Apple machine or the SSD that would get hurt the most - but quite frankly... I don't want to know. Something the guys at Apple already know, I presume.

Just sharing my (not so great) experience...

Important Note!... Please remember that I did NOT persist in using the SSD WITHOUT the patch (i.e. Apple trim enabled).
Since the SSD is a Sandforce controlled device, very recent (firmware release 2.22), I wonder if TRIM would have been active, even when Apple says it is not.

Anyone has experience with recent OCZ SSD (mine is Agility, but the only difference between Agility and Vertex is asynchronous/synchronous RAM, I guess).

Another thing: This machine heats a lot, but never before to the point of asking for a power down - it has a Toshiba 1 Terabyte HDD.

Best regards to All.
mark as good answer

0 people like this answer

share:

36 users following this question, including:

  • ryan
  • user6f4122cd24f
  • jerquiaga
  • ianfogg42
  • tator
  • Hace
  • dave
  • jfanny88
  • jeffreyrr
  • gtmako

This question has been viewed 45558 times.
Last activity .