2014年07月02日00:28:51最新更新:请到这里https://gist.github.com/slagdang/4485183/,支持最新10.9.4。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
#!/bin/bash # # Enable TRIM support for 3rd Party SSDs. Works for Mountain Lion, should work on earlier OSes too. # Tested on 10.8.2, 10.8.3, 10.8.5, 10.9.0, 10.9.1, 10.9.2, 10.9.3, and 10.9.4 # # You may have to re-apply the fix after some system updates, including but not limited to those below: # 10.9.X to 10.9.4 # 10.9.X to 10.9.3 # 10.9.X to 10.9.2 # 10.8.X to 10.8.3 # # Checked for proper operation on 10.8.0, but never booted 10.8.0 with the modified kext. # # Original source: http://digitaldj.net/2011/07/21/trim-enabler-for-lion/ # # To use this, put the contents of this into a file called enable_trim.sh in your home directory # Then, open a Terminal window. In this window, type 'bash enable_trim.sh' (omitting the quotes) # and press return. It will ask for your administrator password. Type this and it will patch the file. # Then simply reboot. # # You can verify that this worked (or if it hasn't been run that it is unneeded) by selecting # "About This Mac" from the Apple menu, then clicking the "More Info..." button, in the new window # click the "System Report" button. In the System Information that opens, select "Serial-ATA" under # "Hardware" in the list on the left. Then click on the item which is your SSD. You will see an item # "TRIM Support:" in the text in the lower right part of the window. If it says "Yes", then TRIM is # working. # set -e set -x # Back up the file we're patching 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 # Patch the file to enable TRIM support # This nulls out the string "APPLE SSD" so that string compares will always pass. # on 10.9.4 the sequence is WakeKey\x0a\0APPLE SSD\0Time To Ready\0 # on 10.8.3 to 10.8.5 and 10.9.0 to 10.9.3, the sequence is Rotational\0APPLE SSD\0Time To Ready\0 # on 10.8.2, the sequence is Rotational\0APPLE SSD\0MacBook5,1\0 # on 10.8.0, the sequence is Rotational\0\0APPLE SSD\0\0\0Queue Depth\0 # The APPLE SSD is to be replaced with a list of nulls of equal length (9). sudo perl -p0777i -e 's@((?:Rotational|WakeKey\x0a)\x00{1,20})APPLE SSD(\x00{1,20}[QMT])@$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2@' \ /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage # Force a reboot of the system's kernel extension cache sudo touch /System/Library/Extensions/ echo "Now reboot!" |
更新到OS X Mavericks,之前开启TRIM的方法失效了。下面介绍用终端这种绿色的方法打开TRIM。
首先打开你的终端,输入以下指令:
1. 为了安全,此步为备份驱动 (可能需要输入密码)
sudo cp -r /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/ /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.BACKUP
2.更新
1 2 |
sudo perl -p0777i -e 's@((?:Rotational|WakeKey\x0a)\x00{1,20})APPLE SSD(\x00{1,20}[QMT])@$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2@' \ /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage |
3.开trim
sudo kextcache -system-prelinked-kernel
4.清除cache
sudo kextcache -system-caches
5. 重启系统。下载脚本