I. enable TRIM
- Backup the file before 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
- [Yosemite only] Disable driver signature check by setting boot-args:
sudo nvram boot-args="kext-dev-mode=1"
- [Yosemite only] Reboot after setting boot-args:
sudo shutdown -r now
- Patch [Yosemite 10.10, Mavericks 10.9.5, 10.9.4] driver:
sudo perl -pi -e 's|(^\x00{1,20})[^\x00]{9}(\x00{1,20}\x54)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
# for Mavericks and Mountain Lion from 10.8.3 to 10.9.3
#sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x54)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
# for Mountain Lion from 10.8.1 to 10.8.2 and Lion 10.7.5
#sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x4D)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
# for Mountain Lion 10.8.0 and Lion 10.7.4 BELOW
#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
- [Yosemite only] Rebuild kext cache (take a while):
sudo kextcache -m /System/Library/Caches/com.apple.kext.caches/Startup/Extensions.mkext /System/Library/Extensions
It will display the message like below:kext-dev-mode allowing invalid signature -67061 0xFFFFFFFFFFFEFA0B for kext IOAHCIBlockStorage.kext
It is fine.
- Now it is time to reboot:
sudo touch /System/Library/Extensions/
sudo shutdown -r now
II. Recovering from stop sign on boot screen
If you stuck on the grey boot screen with a stop sign, here’s how you get back into OS X:
- Boot into recovery mode by holding CMD+R during boot
- If your volume was encrypted with FileVault, open Disk Utility and unlock/mount your drive
- Open the Terminal and run the command:
nvram boot-args
If it shows “kext-dev-mode=1″, you can skip to Step 5. If it says “error getting variable”, continue with Step 4.
- Run the command:
nvram boot-args=kext-dev-mode=1
- Reboot back in to Recovery Mode again.
- Run these commands, replacing Your Disk Name with the name of your Mac disk (partition). You can type ls /Volumes to get a list of volumes. Note the quotes around the disk path and that there should be no / before System.
cd "/Volumes/Your Disk Name"
touch System/Library/Extensions
kextcache -prelinked-kernel System/Library/Caches/com.apple.kext.caches/Startup/kernelcache -K System/Library/Kernels/kernel System/Library/Extensions
- Wait until it finishes (can take as long as 5-10 minutes, don’t abort it) and reboot.
You should now be back in OS X with Trim enabled.
III. Revert back to original driver (TRIM will be disabled)
- Boot into recovery mode by holding CMD+R during boot.
- If your volume was encrypted with FileVault, open Disk Utility and unlock/mount your drive
- Open the Terminal and run the following commands: (Note: the quotes around the disk path and that there should be no / before System, except for the first part of the cp command.)
nvram -d boot-args
cd "/Volumes/Your Disk name"
rm -rf System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
cp -r /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
chown -R root:wheel System/Library/Extensions
chmod -R 755 System/Library/Extensions
touch System/Library/Extensions
kextcache -prelinked-kernel System/Library/Caches/com.apple.kext.caches/Startup/kernelcache -K System/Library/Kernels/kernel System/Library/Extensions
- Wait until it finishes (can take as long as 5-10 minutes, don’t abort it) and reboot.
You should now be back in OS X with Trim disabled.
see also