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

41 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

9 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

share:

Related questions

35 users following this question:

This question has been viewed 26002 times.
Last activity .

Tips for giving the best answers

Sometimes it's just little details that separates a great and not so great answer! Here are a few simple tips to keep in mind:

1
Be complete and thorough. Don't skimp on the details!
2
Try not to answer with a question. Because that's not really an answer, right?
3
A little research goes a long way. Back up your claims and assumptions!
4
Try to be patient, tech questions can be complicated.
5
You are awesome for both reading this and answering questions.