Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Enabling TRIM Support on Mac OS X with Non-Apple SSDs

How To: Enable TRIM with Non-Apple SSD

The guide breaks the process down into three steps, all performed via copying and pasting the code snippets through the terminal window. To launch a terminal window, open the Utilities folder inside the Applications folder and select terminal.

The first step makes a backup of the original IOAHCIBlockStorage file called IOAHCIBlockStorage.original. You will be prompted to enter in your system password when using the "sudo" command, since you are modifying system files. Copy and paste the code into the terminal window, a successful or uneventful response is a new blank terminal line.

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

Next the code patches the IOAHCIBlockStorage file, removing the requirements that the SSD be made by Apple. Copy and paste this code just like the previous command, this step should complete in very little time (seconds or less than a second).

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

The last step loads the newly patched file into the kernel. On a few systems this particular command takes a bit to complete. Expect to see the terminal window wait for 10-15 seconds before a new line appears.

sudo kextcache -system-prelinked-kernel

sudo kextcache -system-caches

Now reboot your system and verify that TRIM is enabled through the System Information on the Serial-ATA device listing. As you can see on the system we performed this modification on, TRIM support is now enabled.

Disabling TRIM support

OR if you want to disable TRIM or completely reverse any changes performed with this guide, two options are available.

The first reverses the changes.

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

The second utilizes the backup file created and restores it over the modified one.

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

Overall the process to enable TRIM on an OSX Lion system is rather painless, with the only requirement being that a SSD that supports TRIM is installed. If you happened to update your notebook or desktop to an SSD, enabling TRIM is a must for the best long term sustained performance.

@DenBeke
Copy link

DenBeke commented Oct 23, 2014

@D33PZ3R0
Copy link

D33PZ3R0 commented May 14, 2015

Take down this POS webpage OR Comment clearly that it's not for Yosemite!
Geeeezus, @degseb simply navigate back to the copy you made of the original delete the POS version you did from these instructions and rename the original. What bad info, always tell Users that this works on x, y, z operating systems versions. Epic Fail

Might also need to mention that once u delete and rename original, depending on what state trim has been put into, u will need to attempt to back out all changes (invoke disable trim procedures) BEFORE REBOOTING.

Copy link

ghost commented Apr 19, 2017

@D33PZ3R0, this post was published in 2013, while Yosemite was not released until October 16, 2014, which means the "problem" you are so passionately moaning about did not exists at the time this post went up. In your own words: Epic Fail!

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