Getting Linux TRIM support to work

Post Reply
cbgoodbuddy
Posts: 21
Joined: Thu Mar 31, 2011 3:51 am

Getting Linux TRIM support to work

Post by cbgoodbuddy »

I have apparently had success to enable TRIM support for my OCZ Vertex 2 SSD. I just wanted to share my technique. (more detailed instructions can be found at http://sites.google.com/site/lightrush/ ... dsonubuntu)

1. I have Linux Mint 9, which has linux 2.6.35. TRIM support has been present in the Linux kernel since version 2.6.33.

2. Make sure your SSD is capable of TRIM. This command:

Code: Select all

    sudo hdparm -I /dev/sda1
should show the phrase "TRIM supported" as an enabled command/feature.

3. Enable TRIM support within Linux by editing your /etc/fstab file and enabling the "discard" option for your root partition. It should look something like this:

Code: Select all

UUID=xxxxxxxx / ext4 discard,defaults,errors=remount-ro,noatime 0 1
The important thing is the "discard" option. I also added the "noatime" option, which disables some disk activity and is harmless. The options must be comma-separated with no spaces allowed.

Reboot your computer with this new file system setting.

It is actually very difficult to find out if TRIM support is working with your SSD or not. You may have the function enabled, but how to you know that it's actually working?

I used the technique described on Andy Duffell's blog (http://andyduffell.com/techblog/?p=852 or http://sites.google.com/site/lightrush/ ... andworking). Basically, his technique shows that when TRIM is enabled, disk sectors of a deleted file are automatically erased to all-zeroes. If TRIM is not working, the disk sectors of a file are not blanked. On my fit-pc2 with Linux Mint 9 (2.6.35), TRIM was working fine. Although I have seen claims that TRIM would only work if AHCI mode was enabled in the Linux controller (and not IDE mode), the Duffell's technique was proof to me that TRIM can work on the fit-pc2.

If you can't get automatic TRIM to work, you may still be able to use the "wiper" program (from http://hdparm.sourceforge.net/)to do it manually. Assuming it works at the command line you could put it in a daily or weekly cron job. You may need to compile a newer version of "hdparm" (available from the same website) in order to allow "wiper" to work.

Hope that helps other people.
Craig

Post Reply

Return to “Linux on fit-PC2”