Skip to content

Instantly share code, notes, and snippets.

@leolimajr
Forked from clarencesong/os-x-enable-trim.md
Created November 21, 2012 11:10
Show Gist options
  • Save leolimajr/4124375 to your computer and use it in GitHub Desktop.
Save leolimajr/4124375 to your computer and use it in GitHub Desktop.
Enable TRIM in OS X 10.8.2 for IOAHCIBlockStorage version 2.3.1
Enable TRIM on non-Apple SSDs in OS X 10.8.2 Mountain Lion.
WARNING: This is ONLY tested on 10.8.2 (IOAHCIBlockStorage version 2.3.1), and NOT earlier or later versions.
Check /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/version.plist
Technical note: The driver changed in 10.8.2 and similar perl commands that worked in earlier OS X versions did not work for me once I updated to 10.8.2.
Run the following commands in Terminal…
1. Backup the original driver
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-backup
2. Modify the driver
sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x54)|$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. 2 commands to clear the system caches to enable OS X to pick up the modified driver
sudo kextcache -system-prelinked-kernel
sudo kextcache -system-caches
sudo touch /System/Library/Extensions/
4. Restart the Mac
@goodloop
Copy link

goodloop commented Mar 5, 2013

Great, successed

@ashoaib
Copy link

ashoaib commented Mar 14, 2013

Thanks for this! This works on 10.8.3 (12D78), IOAHCIBlockStorage version 2.3.1.

@brilligence
Copy link

Thank you. But, it doesn't work for me (IOAHCIBlockStorage ver 2.3.1) and 12D78

Did everything exactly as in the writeup. Any ideas why?

UPDATE: Works with the patcher that I found --> https://github.com/yuezhu/trim_patcher/blob/master/trim_patch.py

@renauddetry
Copy link

Hi,

I'm in the same situation as brilligence.

My SSD is an INTEL SSDSC2CW240A3, and it's plugged into the second SATA port (I removed the optic drive and put an SSD instead). I have an APPLE SSD on the first SATA port.

UPDATE: oops, forgot to update caches :-/. Sorry for the noise.

I ended up backing out of enabling TRIM on 10.8.3 after seeing the number of people who rendered their system unbootable by trying.

@guest4562345
Copy link

Thank you leolimajr! I've been looking all over for this.

I'm running OS X 10.8.3 on INTEL SSDSC2CW240A3. The above code worked for me. I modified my existing bash script to include the "x54" hex code. Previous script used on 10.8.2 (note "x51" diff):

sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\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

@x128
Copy link

x128 commented Mar 28, 2013

Thanks! TRIM enabled on 10.8.3 (12D78), SSD OSZ Vertex 4.

@renauddetry
Copy link

Thanks for the tip guest4562345, working for me as well now.

@tzucc
Copy link

tzucc commented Apr 10, 2013

worked successfully on reboot... Trim Enabler app could not do anything, Leo's script fine as is ... OS X 10.8.3 (12D78) ... Macbook Pro mid June 2012, Samsung Pro 500GB.

@vgorloff
Copy link

Thanks leolimajr! Patch working for me too. 10.8.3 ( 12D78 ) MacMini Mid 2010 with Crucial M4 (CT128M4SSD1).

@hbayindir
Copy link

Thanks a lot leolimajr! It's working on 10.8.3, Early 2008 15" MBP & Intel 335 240GB.

@sp3c73r2038
Copy link

confirmed working on 10.8.3 (12D78) with Crucial M4-CT256M4SSD2 (installed in CD-ROM port)

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment