Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bzerangue/2986122 to your computer and use it in GitHub Desktop.
Save bzerangue/2986122 to your computer and use it in GitHub Desktop.
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.

Copy link


I just install an non apple SSD in my imac and try to enable the TRIM function with your code, but it is not success for me.

When I past the code sudo kextcache -system-prelinked-kernel, it's come up with the message

Kernel file /mach_kernel does not contain request arch: i386

What have I done wrong, please help

Best regards


Copy link

cfree3 commented Aug 1, 2013

@chomchom - I used the -a option to specify my MBP's 64-bit architecture to kextcache:

sudo kextcache -a x86_64 -system-prelinked-kernel
sudo kextcache -a x86_64 -system-caches

That said, the language in the manpage (man kextcache) -- which admittedly I haven't read closely -- leads me to believe that it isn't really a problem:

If no architectures are specified, a default set of architectures supported by the current Mac OS X version is used (Mac OS X 10.6 and later).

Rather, it's just running through all the architectures that your OS X supports.

Copy link

I followed all the steps, but it still shows TRIM Support: No in Serial-ATA category in System Information. Any ideas what could cause that?

Copy link

luismala commented Sep 1, 2013

On my mid 2007 imac I get this error, after the command: kextcache -system-prelinked-kernel

Kernel file /mach_kernel does not contain requested arch: i386
Failed to read file.
Failed to read kernel file.

I tried also with "sudo kextcache -a x86_64 -system-prelinked-kernel" but I get the same error.

Can you help me?

Thanks a lot,


Copy link

Is IOAHCIBlockStorage open source? I can't find it in apple open source website. Overwrite binary looks like an ugly solution. Once apple add any new change, it won't work.

Copy link

itsb commented Jul 30, 2014

WARNING: These instructions do not work on OSX Yosemite! The patch doesn't actually change anything, and worse still, the kextcache updates will render your machine unbootable, because this essential system driver is no longer loaded b/c of the .original backup file that changes the driver signature. Was able to rescue the system by booting the SSD from USB and going through the undo process. For a working TRIM solution use the Trim Enabler software package ( It's free and works in Yosemite, carefully read their comments sections before using it (

Copy link

degseb commented Oct 21, 2014

I have apply the patch on Yosemite after installing it, I forgot that this patch wasn't ready for Yosemite!
Does somebody have instructions for me, to restore old kext,... ? My mac does boot anymore :(
Thank you.

Copy link

DenBeke commented Oct 23, 2014

Copy link

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