Skip to content

Instantly share code, notes, and snippets.

@return1
Last active May 26, 2024 11:01
Show Gist options
  • Save return1/4058659 to your computer and use it in GitHub Desktop.
Save return1/4058659 to your computer and use it in GitHub Desktop.
TRIM Enabler for OS X Yosemite 10.10.3
#
# UPDATE for 10.10.4+: please consider this patch obsolete, as apple provides a tool called "trimforce" to enable trim support for 3rd party SSDs
# just run "sudo trimforce enable" to activate the trim support from now on!
#
# Original version by Grant Parnell is offline (http://digitaldj.net/2011/07/21/trim-enabler-for-lion/)
# Update July 2014: no longer offline, see https://digitaldj.net/blog/2011/11/17/trim-enabler-for-os-x-lion-mountain-lion-mavericks/
#
# Looks for "Apple" string in HD kext, changes it to a wildcard match for anything
#
# Alternative to http://www.groths.org/trim-enabler-3-0-released/
# Method behind this madness described: http://forums.macrumors.com/showthread.php?t=1409151&page=4
# See discussion in comments here: https://www.macupdate.com/app/mac/39654/lion-tweaks
# And here: http://forums.macrumors.com/showthread.php?t=1410459
# And here: http://forums.macrumors.com/showthread.php?t=1480302
#
# Yosemite: for recovering from stop sign on boot screen, please see http://www.cindori.org/update-on-trim-in-yosemite/
# backup patched file
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
# Important: Add "kext-dev-mode=1" as Kernel Arguments or the computer won't boot.
sudo nvram boot-args="kext-dev-mode=1"
sudo shutdown -r now
# looks for "Apple" string in HD kext, changes it to a wildcard match for anything
sudo perl -pi -e 's|\x00\x41\x50\x50\x4c\x45\x20\x53\x53\x44\x00|\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00|' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
# rebuild kext cache manually (could take a while)
sudo touch /System/Library/Extensions
sudo kextcache -m /System/Library/Caches/com.apple.kext.caches/Startup/Extensions.mkext /System/Library/Extensions
# now reboot!
sudo shutdown -r now
@ralfbergs
Copy link

This script still works in 10.10.4 public beta (10.10.4 (14E11f)).

@cundi
Copy link

cundi commented May 12, 2015

confirmed. It works on 10.10.3
容量: 256.06 GB(256,060,514,304 字节)
型号: PLEXTOR PX-256M6S
修正版: 1.070000
序列号: P02431100565
原生命令队列: 是
队列深度: 32
活动盘片: 否
可拆卸的驱动器: 否
BSD 名称: disk0
介质类型: 固态
TRIM 支持: 是

@ralfbergs
Copy link

This script still works under public beta 10.10.4 (14E17e).

@mashrum
Copy link

mashrum commented May 20, 2015

MacBook Pro 6,1 (17' Mid-2010), 10.10.3, Samsung 850 pro 1T = Ok!
Thank you.

@eduardonunesp
Copy link

MacBook Pro (13-inch, Early 2011), 10.10.3, KINGSTON SV300S37A240G
Works !

@chka
Copy link

chka commented May 27, 2015

MacBook Pro (13-inch, Mid 2012), 10.10.3, Samsung SSD 840 EVO 250GB
Works perfectly

@ralfbergs
Copy link

This script still works under public beta 10.10.4 (14E26a).

@herrernst
Copy link

I wonder if it even is necessary to keep kext-dev-mode enabled? I just booted without it, but still having trim enabled (10.10.3).
screen shot 2015-05-30 at 15 35 16
Of course, if somehow the kernel caches get regenerated, the patched extension will be skipped and you can't boot (you have to repair from recovery partition or USB/DVD as explained here).
By the way: kextcache doesn't directly check the NVRAM value, but the sysctl settings of kern.bootargs (see function isDevMode() at http://www.opensource.apple.com/source/kext_tools/kext_tools-384.1.4/security.c). Unfortunately, the sysctl value is still read-only and can only be set on boot time via NVRAM.

@oniksfly
Copy link

Worked for me with OS X 10.10.3 on macbook pro mid 2009, SSD Corsair Neutron.

@khpatel4991
Copy link

How to use this script from windows or MAC?

@herrernst
Copy link

@khpatel4991 You'd have to enter those commands in Mac OS X Terminal (in Applications - Utilities). If this is too complicated for you, you're better off using [https://www.cindori.org/software/trimenabler/](Trim Enabler).

@ralfbergs
Copy link

This script still works under public beta 10.10.4 (14E33b)

@highks
Copy link

highks commented Jun 16, 2015

I just read the happy news that in OSX El Capitan, there will probably be an official OSX-tool named Trimforce, which enables TRIM for all SSDs if the user chooses to do so. Without having to deactivate the kext-signing, that is!

http://9to5mac.com/2015/06/12/os-x-ssd-trim-support-el-capitan/

I really hope this is true, it would prove that Apple is still able to make sane decisions and listen to their users!

@ralfbergs
Copy link

This script still works under public beta10.10.4 (14E36b)

@HofiOne
Copy link

HofiOne commented Jun 18, 2015

OCZ-AGILITY3 10.10.3
OK!
thanks!

Copy link

ghost commented Jun 28, 2015

MacBook Pro (15-inch, Late 2011), 10.10.3, Crucial CT500MX200SSD1
It works! Thanks!

@TechFounder
Copy link

With the new 10.10.4 trimforce now enabled, do we still need this?

I think it's just a matter of running sudo trimforce enable in your terminal right?

@ralfbergs
Copy link

@TechFounder: Confirmed. This patch is no longer required.

@lboecker
Copy link

lboecker commented Jul 1, 2015

@TechFounder @ralfbergs This is great news. Thanks for sharing!

BTW: Make sure you undo the changes the script made after updating to 10.10.4. Something like:

sudo rm /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage.original
sudo nvram -d boot-args
# Not sure if these are really necessary
sudo touch /System/Library/Extensions
sudo kextcache -m /System/Library/Caches/com.apple.kext.caches/Startup/Extensions.mkext /System/Library/Extensions
# Reboot and run `sudo trimforce enable`

@gchriswill
Copy link

sudo trimforce enable

Yesterday, Apple had released OS X 10.10.4, including on it the new remarkable trimforce tool which allow native TRIM support for 3rd parties SSDs. This is a huge win for the Mac users community because the people had ask for this a while ago. I believe that Apple had made this decision because after the release of OS X Yosemite, which includes the new kext signing feature, Mac users were disabling this security feature, which when turned off, allows to execute arbitrary code in modified kext extension natively, WHICH was an huge security flaw. This been said, I guess Apple would rather prefer to allow their Macs to support 3rd parties SSDs and have Macs secured, than have a lot of hacked Macs and all the internet taking about it...

Although, old Macs are getting obsolete due to the absence of current technologies, most of the regular users still can extract a bit more juice of their Macs, so they will find this tool very useful. As for power users, I recommend just buying a new Mac...

@pvl7
Copy link

pvl7 commented Jul 2, 2015

"sudo trimforce enable" didn't work for me on 10.10.4. Still had to use the script to change the driver signature and disable security checks :(

@nychan
Copy link

nychan commented Jul 12, 2015

I got some issue when disabling the changes done by this script and booted to the STOP sign screen after using sudo trim force enable, one of the crucial thing I missed when disabling the patched driver is I did not remove the patched driver file in "/Volumes/Your Disk Name", seems the guide in the link is good enough for me to fix https://www.cindori.org/trim-enabler-and-yosemite/, though I did mistyped chown/chmod lucky no permanent damage is done anyway, after all the mess I did at least it is working for the TRIM without a patched driver under 10.10.4!

@howtosayhello
Copy link

Used this script, even for 10.10.4, always perfect, thanks

@ctismer
Copy link

ctismer commented Aug 21, 2015

but it no longer works with 10.10.5 :-(

@drichardson
Copy link

Anyone tried with El Capitan 10.11 yet? I'm getting an Operation not permitted error when trying to make the backup of the driver in the first step.

@return1
Copy link
Author

return1 commented Oct 16, 2015

for 10.10.4 and higher it is just: sudo trimforce enable

@defycgn
Copy link

defycgn commented Nov 14, 2015

New Solution worked for me on OS X El Capitan 10.11.2 Beta (15X40a)

@wviana
Copy link

wviana commented May 30, 2016

KINGSTON SV300S37A
Confirmed, in my case a 240G (KINGSTON SV300S37A240G)
by: sudo trimforce enable
Mac OS X: 10.11.5

@brianonn
Copy link

PLEXTOR PX-256M6S
confirmed works with 10.9.5 on Early 2008 imac8,1

@nkichukov
Copy link

'trimforce enable' worked like a charm on HighSierra. Thank you so much!

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