UPDATE: There is now a way to enable TRIM support on OSX 10.6.7 with an unsupported hack. Information on that is here.
A while back I wrote this post showing the benefits of putting a SSD in your notebook. The speed is fantastic and it’s really the best upgrade you can do to a workstation right now. Be careful though, after a while you get spoiled and want them in all your systems!
Usually I find Apple’s OSX to be superior to other operating systems for what I do, but it has one big gap when it comes to using SSDs. It does not support TRIM. Why is this important? Because without TRIM support over time the write speed on your SSD will degrade. Reads always stay fast, but writes start taking a lot longer. I won’t go in to an explanation here as others have already done a very good job. One example is here at Anandtech. If you keep a lot of free space on your SSD you can greatly prolong the time before writes start to degrade, but since SSDs are usually smaller than normal disks it can be hard to do.
Note that not all SSDs support TRIM and some require firmware updates to add the feature. So before you start this process make sure your drive supports it or else you won’t see any benefit from doing this. I use an Intel X25G2 160GB SSD which supports TRIM with later firmware versions. If your SSD does not support TRIM there are other manual methods to refresh them, but this won’t do it. Google is your friend!
Lately I’ve been noticing some things starting to slow down on my MacBook Pro. I’m seeing applications stutter and pause and that wasn’t happening before. Since OSX doesn’t yet (What’s the deal Steve?) support TRIM I had to manually “refresh” my SSD back to original speed. Here were my degraded disk benchmark numbers from Xbench:
Sequential Uncached Write: 65.49MB/sec [4K blocks] Uncached Write: 97.35MB/sec [256K blocks] Uncached Read: 50.78MB/sec [4K blocks] Uncached Read: 200.86MB [256K blocks] RandomUncached Write: 25.86MB/sec [4K blocks] Uncached Write: 36.09MB/sec [256K blocks] Uncached Read: 5.22MB/sec [4K blocks] Uncached Read: 176.47MB [256K blocks]The process to refresh the SSD isn't complicated but it is destructive so you need to backup your system. If you aren't using Time Machine to backup your Mac stop reading this and go start. It's the easiest personal backup system you'll find and you can do a bare metal restore of your Mac very quickly and all you need is an external USB disk or supported network drive. DO IT! Before you start do a backup to make sure you're Time Machine archive is current.
We will be using some Linux tools to do this so the next step is to download the latest Ubuntu ISO file here. I use the normal 32-bit image. You'll need to burn this ISO file to a blank disc. You should be able to image it to a USB thumb drive and boot from that but I never could get that to work but a blank CD-R worked fine. So burn the ISO, reboot your Mac while holding the ALT key, then select the CD as the boot source. Holding down C while booting should also tell your system to boot directly to the CD. Whatever you prefer.
At this point you have two options. The Ubuntu disc can either be used to do a full install or you can boot to an "in-memory" system to try Ubuntu before install. In the end you'll use the same tools but if you do the trial in-memory method you'll have to manually partition and format your SSD while the install does it for you. Be sure to format it with the ext4 filesystem. If you're a Linux person you can do the trial and probably save a little time...for others....
Do a normal install of Ubuntu to your SSD. Just follow through the prompts and let it format your drive. After you finish go ahead and log in as the account you created during install. Once in the desktop start the Terminal under Applications. From the command-line you need to install the gawk package. Do this by typing:
sudo apt-get install gawkYou'll be prompted for your password and then the system will download and install gawk. The next step is to open the web browser. Its icon is on the menu bar at the top. From there go download the hdparm toolset from here. When prompted by the browser just have it save the file to your home directory. Once downloaded go back to the Terminal window and do an ls to make sure the file is in your home directory. If so type tar xvf hdparm-XXXX.tar.gz (Replace XXXX with the version number) to unarchive the hdparm package. Next you will change in to the newly unpacked directory, and then again change to the wiper directory. Finally, run the wiper.sh command by typing:
./wiper.sh --commit /dev/sda2If you did a normal install the root partition should be /dev/sda2. If not adjust the command-line for your system. Hopefully you'll see output resembling this:
wiper.sh: Linux SATA SSD TRIM utility, version 2.5, by Mark Lord. Preparing for online TRIM of free space on /dev/sda2 (ext4 mounted read-write at /). This operation could silently destroy your data. Are you sure (y/N)? y Creating temporary file (24390500 KB).. Syncing disks.. Beginning TRIM operations.. /dev/sdc: trimming 27099135 sectors from 512 ranges succeeded *** Similar lines deleted for brevity *** Removing temporary file.. Syncing disks.. Done.The process is very quick so don't be surprised when it's done in just a second or two. If there is a problem you may get an error such as:
FAILED: Input/output errorThis can mean several things. Check to make sure your drive supports TRIM. You may also need another version of wiper.sh. In fact, I had to get an older version for my system. For some reason the latest version of wiper.sh would error on my system yet it worked for some others. So if your SSD supports TRIM but you still get this error try an older version of wiper.sh.
Assuming all is good, that's it! Put a Snow Leopard disc in your system, reboot, hold down C to boot from the disc, and then tell it to restore your entire system from the Time Machine backup. Your system should be back to full speed. Here are my benchmark numbers after the refresh:
Sequential Uncached Write: 111.86MB/sec [4K blocks] Uncached Write: 98.37MB/sec [256K blocks] Uncached Read: 49.94MB/sec [4K blocks] Uncached Read: 206.07MB [256K blocks] RandomUncached Write: 82.99MB/sec [4K blocks] Uncached Write: 101.69MB/sec [256K blocks] Uncached Read: 16.17MB/sec [4K blocks] Uncached Read: 178.74MB [256K blocks]That's pretty much a 3x increase in write speed! Very nice and worth the time.



Uhm you could save hours by using a SSD that uses over-provisioning and never need to TRIM and the hours burned.
Regardless, what you wrote was coherent and well written, thank you!
[...] Getting Your SSD Back to Full Speed in OSX « Jason Nash’s Blog (tags: SSD OSX) « links for 2010-11-14 | [...]
[...] with OSX. Time Machine is really a killer feature of OSX IMHO. I followed the instructions on Jason Nash’s Blog to perform the TRIM [...]
[...] Getting Your SSD Back to Full Speed in OSX (tags: osx ssd hardware tuning) [...]
[...] I wrote this post on how to “refresh” an SSD with OSX, since OSX didn’t (and still technically [...]