Does Ubuntu have support for the TRIM command for use with SSD?

SSD drives need to be "cleared/reset" after the drive fills up to maintain performance. This is done through the TRIM command for new SSD drives. Does Ubuntu support the TRIM command (through hdparm etc) for clearing/resetting of these drives?


Looks like there is support for the TRIM functionality in the 10.10 and newer releases:

  • How do I optimize the OS for SSDs?

Also, the TRIM stuff happens automatically - empty blocks are automatically released when they're no longer needed (eg, you delete a file), if the disk reports that it supports TRIM. You don't have to manually issue a hdparm command for this to work.


Jeremy's answer is not entirely accurate AFAIK. I've been running the latest stable kernels on Lucid for some time now and have been following the status of TRIM quite keenly as I have an OCZ Agility as my main disk.

Here's what (I think) I know:

  • The kernel has TRIM support as of 2.6.33 (Maverick is 2.6.35).

  • EXT4 has TRIM support but only when journaling is turned off.

  • The way TRIM works in the kernel is very basic and quite slow. Disks following the specs can accept multiple ranges but the kernel currently can only do one range at a time. This comes from something I read perhaps a month ago. I wish I had the source as this might not be true or might no longer apply.

Journalling is what kills it for me. Data corruption is a PITA.

However the newer versions of hdparm (v9.25 - Maverick is at v9.27) come with a script called wiper.sh which performs a quick analysis of a drive and then trims all the empty space. Rather than lose features, I find it much easier to cron wiper.sh to run once a week (or once a day/month/whatever). SSD degradation for an OS drive doesn't happen that fast unless you're constantly tearing things up. You don't need realtime TRIMming.

There is also a GUI frontend called DiskTRIM which doesn't appear to be in the repos. Less experienced users might find this easier to use than setting up cron jobs.

There are PPAs for hdparm and disktrim and all can be run on Lucid (and further back) without need for 2.6.33+ kernels.