Create a gist now

Instantly share code, notes, and snippets.

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
@0ver387

Thank you

@TechFounder

Any idea if 10.8.5 will break TRIM? I'm a bit afraid to update.

@return1
Owner

it works on 10.8.5, tried it out myself.

@TechFounder

Excellent, thanks!

Is there a reason you omit the two lines which will clear the cache?

sudo kextcache -system-prelinked-kernel

sudo kextcache -system-caches

@N4M3Z

Confirmed. Works with 10.8.5.

@SnakeO

Thank you. Confirmed working on 10.8.4 with Samsung SSD 840 Series

@ghost

Thanks a Lot. (Working on 10.8.5 with OCZ Vector)

@veresdaniel

hi,

thanks for this script. I had success on Mac mini (10.8.5) with it, but seems not working on my hacintosh 10.9GM (OCZ-VERTEX3).

@tboerstad

Hi,

I am also using OCZ-VERTEX3. Suddenly today, after nothing more than a reboot, my mac refused to boot and went to the "no entry" grey screen. I did a verbose boot (alt-command v), and got a repeating error message saying "still waiting for root device".

I traced this error message to "IOAHCIBlockStorage.kext". After running the perl command, and rebooting, my macbook is up and running again. Thanks a lot

@N4M3Z

Can more people please confirm if this does work on 10.9 GM?

@TechFounder

Anyone tried it on Mavericks (10.9)?

@127-0-0-1

Tried script for Mountain Lion 10.8.3 - 10.8.5 on 10.9
it works!

@return1
Owner

does work with 10.9

@michaelcoluzzi

Works with 10.9 with SanDisk UltraPlus 256G aka SanDisk SDSSDH2256G

@duderman

Works great! Thank you!
10.9.2 md313 KINGSTON SV300S37A120G

@DenimTornado

10.9.2 OCZ-VECTOR Works, thanks!

@prakdavid

Confirmed. Works on 10.9.2 with Samsung SSD 840 Pro Series

@ghost

Confirmed works with 10.9.2 with Crucial M550 1TB SSD. :)

@ershovandrey

Works with 10.9.3 with Samsung 830 256Gb

@kevan

THANKS!!!

Works with 10.9.3 with M4-CT512M4SSD2 512GB

@ghost

not working anymore with 10.9.4 please provide an update

@return1
Owner

works for 10.9.4 now

@oak8292

Confirmed for 10.9.4 with a Plextor 256GB M6e. Thanks!!!!

@racsantos

Confirmed for 10.9.4, KINGSTON SV300S37A120G Thanks!

@fritztoch

Works for 10.9.4, MacBookPro5,5, OCZ-AGILITY3 (setup as a Fusion drive with a WDC WD10JPVX).

@superlukas

Samsung 840 PRO
Confirmed: 10.9.4, 10.9.5, 10.10, 10.10.1, 10.10.2
10.10.3: See @andrewpsy

@DrizzlyOwl

Confirmed for 10.9.4 KINGSTON SV300S37A240G

@sBaildon

Confirming OS X 10.9.4 Samsung 840 EVO

@ggreco

I can add that this works also on 10.10 DP4, the previous version worked until DP2, it seems that 10.9.4 and 10.10 DP3+ share the same SSD driver :)

@markhammond

Confirmed working for OS X 10.9.4 PLEXTOR PX-512M6Pro (rev 1.01)

Beware: after 3 days of steady use I encountering random beach balling, culminating in losing the boot sector. I wasn't able to restore the boot partition or repair the disk. Similar reports on the plextor user forum.

@morube

Confirmed for 10.9.4, Samsung 840 EVO

@pderby

Confirmed for 10.9.5 13F24, Samsung 850 PRO 1TB running on MacMini 3,1

@mklengel

Confirmed for 10.9.5 (13F34), Samsung 840 PRO 256 GB on MacPro4,1

@spherique

Also confirmed for OS X 10.9.5 (13F34), PLEXTOR PX-256M5Pro (rev 1,06) on Macmini6,2

@kassner

Confirmed for 10.9.5 (13F34), Kingston SV300S37A120G, MacbookPro5,5

@DeathBorn

Works macbook5.1 (late 2008) with OS X 10.9.5, 8GB RAM, Samsung SSD 840 EVO. Also shows
Link Speed: 3 Gigabit
Negotiated Link Speed: 3 Gigabit
SUPERB!

@sollarman

Thank you!

@chrboehm

Confirmed for 10.9.5, Crucial_CT512MX100SSD1, MacBook Pro late 2011

@Mo-Tech

Doesn't work with 10.9.5 & 256GB Samsung 850 Pro SSD. Takes all command, gives no error but no TRIM support after reboot. I have SSD connected on MacPro 5,1 (beneth the Superdrive, not into HD socket due to missing adapter). What can be wrong - SATA cable not the same as SATA socket or something about the software?

@leyafo

Thanks, you‘re good man。

@metsma

For Yosemite you have to disable driver signature check
sudo nvram boot-args="kext-dev-mode=1"
http://www.cindori.org/enabling-trim-on-os-x-yosemite/

@TechFounder

This will break Yosemite final release so please don't use it.

Perhaps you need to rebuild kext cache?
# rebuild kext cache
sudo kextcache -prelinked-kernel /System/Library/Caches/com.apple.kext.cache/Startup/kernelcache -K /System/Library/Kernels/kernel /System/Library/Extensions

Any idea how to fix now that my computer won't boot correctly?

Update: disk repair won't fix this. I had to reinstall Yosemite from my boot partition.

Someone should try this guy's version to see if that works: https://gist.github.com/rizal72/0f738cc6735744f84bb3

I've already done my good deed for today.

@return1
Owner

no, it still works. if you get stuck on reboot, please use this instructions, skipping the Trim Enabler Part: http://www.cindori.org/enabling-trim-on-os-x-yosemite/

@return1
Owner

updated instructions for yosemite to prevent the boot screen lock according to http://www.cindori.org/enabling-trim-on-os-x-yosemite/

@megamosk

OSX 10.10
Crucial m4 ct256m4ssd2
TRIM Support: Yes
Thanks!

@ivanke

Confirmed for OS X 10.10 ( MacBook Pro 13-inch, 2012 mid )
PLEXTOR PX-128M5S
Trim Support: Yes
Thanks a million

@TechFounder

Thanks, your revised instructions worked with Yosemite.

@HPM41

osx 10.10
mac book mid 2009
all instructions entered
got the message: kext-dev-mode allowing invalid signature -67061 ....
nevertheless: trim seems to work
thanks

@psousa

Worked for me.
osx 10.10
mac book mid 2010
ocz ssd

Trim works. Thanks!

@maartentromp

Works on my Late 2011 Macbook Pro 13 with 10.10 with Samsung SSD 840 EVO 750GB

@kike1

i still get Trim enabler: No after run the script. What happened? i have a KINGSTON SV300S37A120G

@superlukas

@kike1 The commands after the first shutdown command are never executed. Somebody should probably change the name of the Gist. Anyway, just copy and paste the commands one by one.

@BrainClot

Thank you! Works on Yosemite 10.10.1

@Haramac

Thank you very much! It works perfectly: Crucial M4 (firmware 070H) + Yesomite 10.10.1 :)

@ivanke

Confirmed for OS X 10.10.1 ( MacBook Pro 13-inch, 2012 mid )
PLEXTOR PX-128M5S
Trim Support: Yes
Thanks a million

@sman591

Doesn't work for me - 2009 MacBook Pro + 120GB SanDisk Extreme...

@pakpenyo

Work perfectly for 10.10 clean install, then stuck with white circle grey background while update to 10.10.1. But its working after recovering and re enable. (Samsung 840pro 256Gb - MBP 15" early 2011).

@blackgat

This worked for me on MacBook (13-inch, Mid 2010) with 240G Intel 530 Series at 10.10.1 clean environment.

@cpBurn

I just did it on OS X Yosemite 10.10.1 on a clean install. Worked like a charm.

@WildPenquin

Thanks! Seems to work on Yosemite for me on my Kingston V300.

@nobbs

Still working with 10.10.2 Public Beta.

@praetor1an

How do I disable TRIM on 10.9 before upgrading to 10.10?

@matbhz

Funny, I didn't work on my Yosemite 10.10.1.
Any extra steps you guys above took?

PS: In any case I downloaded Trim Enabler but I am curious to understand why this didn't work.

@zadorozhko

Confirmed for 10.10.1 and Samsung SSD 850 PRO. Thanks!

@beh

Works like a charm with 10.10.1 and a fusion drive setup with an Intel 330 120GB and a stock 1TB HDD.

@Haramac

Works perfect on 10.10.2, but after the update you need to turn it on again.

@sourcerebels

Thanks. This works perfect on Yosemite with Crucial MX100 256 GB in a 2012 Macbook pro.

@drichardson

Worked for me. Samsung 850 EVO 500GB on mid 2012 MacBook Pro with Yosemite 10.10.2 and Samsung EVO 250GB on 2011 MacBook Pro with Yosemite 10.10.2.

I also wrote a tool called TRIMCheck that verifies TRIM is enabled on your SSD drives at each boot and shows a warning message if it is not. This is intended to remind you to rerun the steps in this gist in case an OS X update has updated the kext driver patched by these instructions.

https://github.com/drichardson/TRIMCheck

@tom-san

The shell script works well on Mavericks 10.9.5.

An additional tip regarding TRIM using Yosemite:

  • Prepare a Mavericks boot drive using Disk Utility (USB stick / old USB HDD should do)
  • Boot to this drive and modify using the shell script above
  • After rebooting to this drive verify that all 3rd party SSD drives in the system show "TRIM Support: Yes" (About this mac -> More Info -> System report -> SATA/SATA Express -> {your SSD drive} )
  • Boot every once in awhile to this drive (e.g. once a week) and run Disk utility choosing "Repair Disk" on your third party SSD.
  • Observe occurrence of prompt message "Trim unused space"

This way you won't have to mess with the kext signing still preventing write amplification.

Please note: That worked for me on a Samsung 840. Maybe some SSD drives fail on the OS's TRIM command. So, please use at your own risk and better yet, make a backup prior to your first attempt.

@mezhaka

It did not work for me with my X25-E Intel SSD drive. (Yosemite 10.10.2, MacBook Pro, Late 2008). I tried it several times but I still get TRIM Support: No in the System Report. The Internets are controversial about why is that: some write that the SLC based SSD drives do not need TRIM, some argue.

@Bialykot

The script works fine on a Yosemite Macbook Pro with Samsung 840 Pro SSD. However, I understand that if I upgrade to a newer revision of Yosemite in the future, the kext signing may be switched on again by the upgrade, which will mean I won't be able to boot the computer (as TRIM is set to on).

I'm very new to all of this so what are the steps for disabling TRIM before any upgrades, please?

@robertcedwards

Thank you!!!

@managr

This is so cool. Samsung SSD 840 PRO Series says:
TRIM Support: Yes
Thanks!

@GaborTB

If I used the SDD for long without TRIM enabled and apply this script, does OSX zero out all pages that are currently filled up with deleted file data on the SSD retroactively?

@hfoffani

@Bialykot What happens after a kernel upgrade is that Yosemite turns TRIM off. You'll be able to boot but TRIM is deactivated and you need to apply the procedure again. Of course, there's no guarantee here...
I had automatic upgrades switched off and always check this site before upgrading.

@Bialykot

hfoffani - thanks for that. I've just installed the latest security patch to Yosemite 10.10.2 and all went OK and TRIM was still enabled after the update. BUT ... what if there is a more major patch/upgrade to Yosemite - e.g. to 10.11? would I have to disable TRIM before applying the upgrade? And if so, what are the exact steps / script to do this? Sorry if the questions seem a bit naive. Just want to be as sure as I can not to mess up my BBP. (I do have a full backup but this takes several hours).

BTW - the TRIM really works well on my Samsung 840 pro. Without TRIM I was getting 50-100Mb/s write speeds but with it activated I always get around 500Mb/s. :)

@hfoffani

Bialykot. No, you don't need to anything. After upgrading, you'll see that TRIM is unsupported again so you have to apply this patch (or the corresponding one) again. That's why many of us had switched off OS X autoupdates. It's better to check this site before upgrading in case some incompatibilities appears in a future version.

@phmich

Thank you for that, it works for me

  • Yosemite version 10.10.2 (14C1510) and
  • SSD Kingston SVP100S512G

by the way, I have 2 SSD in my macbook pro 17inch

  • original Apple SSD 128Gb with OSX on it
  • additional SSD 521Gb for data and virtual machines at the place of the superdrive.

I expect that OSX update will not affect the original SSD, but will may be affect the additional SSD
I do not know how it will happens, but I suppose I will be able to patch again the
sudo nvram boot-args="kext-dev-mode=1" and the reboot to get back to my data SSD

@smiera

Thank you! 10.10.2 and Samsung SSD 840 EVO work great.

@rbfinch

It doesn't appear to be working after the 10.10.3 update. After running the perl line the driver is unchanged, so it seems that we'll need a new pattern to search for.

@beh
beh commented Apr 8, 2015

Same result as rbfinch, the perl reg-exp magic does nothing on 10.10.3

@andrewpsy

replace the perl command with this one worked for me:
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

source http://www.insanelymac.com/forum/topic/298507-enable-trim-on-non-apple-ssd/

@petermolnar-hu

Thanks andrewpsy, you saved my day;). The new perl script line worked for me as well.

@return1
Owner

updated for 10.10.3, thanks @andrewpsy

@beh
beh commented Apr 9, 2015

Thanks, worked like a charm

@pvl7

Thank you!
mid-2012 10.10.3 + Samsung Evo 850 500Gb - worked fine!

@nychan

working great with late 2009 unibody macbook + 10.10.3 + OCZ Agitility 3

@todesto

Thank you, works great with my 2010 macbook pro + Corsair SSD.
My question is how do you disable before system update?

@francisceril

How can I revert back or disable it because I have a new update which fixes graphics for my iMac? Please help.

@highks

Thank you very much, this works very well on a Macpro 2013 with four Samsung 840 EVO in an Akitio Thunder2Quad case (which is a Thunderbolt 2 case with four SATA Slots, the drives are configured as a RAID 1+0 in OSX 10.10.3)
I am very happy this works, because for my setup here, there isn't even any solution by Apple that I could get instead. First they promote the Macpro with all these great, super fast Thunderbolt connections, and then they deactivate TRIM for basically all SSDs connected by Thunderbolt... thanks again, Apple! (sarcastically!)

@ralfbergs

@francisceril: You don't have to for such a small update. It's not a complete OS update you are mentioning...

@ralfbergs

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

@cundi

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

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

@mashrum

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

@eduardonunesp

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

@chka

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

@ralfbergs

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

@herrernst

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

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

@khpatel4991

How to use this script from windows or MAC?

@herrernst

@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/.

@ralfbergs

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

@highks

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

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

@HofiOne

OCZ-AGILITY3 10.10.3
OK!
thanks!

@cm-ttamiya

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

@TechFounder

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

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

@superlukas

@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

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

"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

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

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

@ctismer

but it no longer works with 10.10.5 :-(

@drichardson

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
Owner

for 10.10.4 and higher it is just: sudo trimforce enable

@defycgn

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

@wviana
wviana commented May 30, 2016 edited

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

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