Skip to content

Instantly share code, notes, and snippets.

@danielmt
Forked from bylatt/optimize-ssd.md
Created September 20, 2016 21:32
Show Gist options
  • Save danielmt/f9b7d0121e3324f124f40734594f39cb to your computer and use it in GitHub Desktop.
Save danielmt/f9b7d0121e3324f124f40734594f39cb to your computer and use it in GitHub Desktop.
Optimize non-Apple SSDs on OS X.

Optimize non-Apple SSDs on OS X. (Run the following commands in the terminal.)

Enable TRIM support

Check IOAHCIBlockStorage version:

open /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/version.plist

Backup the original driver:

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

Modify the driver:

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

Clear the system caches:

sudo kextcache -system-prelinked-kernel
sudo kextcache -system-caches
sudo touch /System/Library/Extensions/

Restart the mac:

Set/Unset SMS

To check SMS status:

sudo pmset -g

if return 1 enabled, if 0 disabled

To disable:

sudo pmset -a sms 0

To enable:

sudo pmset -a sms 1

Create plist file:

sudo vim /Library/LaunchDaemons/com.noatime.plist

Then paste this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.noatime</string>
<key>ProgramArguments</key>
<array>
<string>mount</string>
<string>-uwo</string>
<string>noatime</string>
<string>/</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>

Save and reboot then checking with command:

mount | grep " / "

you should see /dev/disk0s2 on / (hfs, local, journaled, noatime).

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