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?

  • Good question, though note that the degree to which TRIM improves performance does vary amongst SSDs, for some it doesn't make as much difference as you'd think (though they mostly seem to be the slower ones anyway). Jul 29, 2010 at 2:36
  • 1
    I think the performance would be restored to the same (if not close to) the factory defaults. Have a look here for an explanation -> anandtech.com/show/2738/10
    – ssanj
    Jul 29, 2010 at 3:30

5 Answers 5


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

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.

  • I thought you still had to use tools which "sent" the TRIM command to the SDD. It's good if it works as you specify. :) This Anandtech article -> (anandtech.com/show/2738/10) specifies that for TRIM to work, both the OS and the SSD need TRIM support. I guess my question is about the OS/Linux support for TRIM when used with TRIM-aware SSD drives.
    – ssanj
    Jul 29, 2010 at 3:29
  • 3
    The TRIM command needs to know which block(s) to free up, so it'd be dangerous issuing this without knowing exactly which blocks on the disk are not used. Yes, both the OS and the disk need to have trim support. In Linux, this was added in kernel version 2.6.33, so will be included in Maverick. Both the disk driver the filesystem you're using need to support trim for this to properly work. If you're using ext4 as your filesystem on Maverick, you should be fine. Jul 29, 2010 at 3:43
  • I wonder then whether it will be possible for existing SSDs to undergo a "retrofitted TRIM" in order to clean up the existing cruft accumulated prior to the OS supporting TRIM. Or would a reinstall be required? Sep 3, 2010 at 12:08

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.

  • Can you link to those PPAs please? Sep 22, 2010 at 15:57
  • So does enabling the discard mount option for ext4 disable journalling? I've just been searching for references but I can't find one apart from this answer - can you provide a source? Mar 4, 2012 at 12:19
  • 2
    in Ubuntu 12.04 the wiper.sh has been replaced with fstrim
    – tomodachi
    May 7, 2012 at 22:40
  • 1
    @Oli: I've done some more reading and I'm now pretty sure that the discard option does not disable the journal. Afaict originally the discard option only worked with the journal (I found this patch that allows discard without the journal). The kernel ext4 page documents the discard option but does not mention the journal is incompatible. May 12, 2012 at 20:09

Linux has support for automatic TRIM with ETX4 file system since kernel 2.6.33.

The first Ubuntu release with automatic TRIM support is 10.10 (Maveric), but it has to be activated in fstab (as described here).


In general, yes, because there are a bevy of ways to obtain newer kernels. If we clarify your question to read, "Does 10.04 LTS have support out of the box for the command?" then the answer is no. However, both Maverick's and Natty's kernels (-generic, -generic-pae, -server, and -virtual flavors) have been backported to 10.04 LTS and are available from $release-updates in the Ubuntu repositories, e.g., linux-image-generic-lts-backport-maverick is Maverick's backport to Lucid.


I'm running 11.04 and it doesn't look like TRIM is working according out of the box.

I tested using the instructions here to create a file, delete it, and see if the sectors get zeroed out/deleted.

I tried to enable TRIM using the instructions here, but no dice

I run wiper.sh, I get

/sbin/wiper.sh --verbose --commit /dev/sda1
wiper.sh: Linux SATA SSD TRIM utility, version 3.3, by Mark Lord.
fsmode2: fsmode=read-write
/: fstype=ext4
freesize = 13785252 KB, reserved = 137852 KB
Preparing for online TRIM of free space on /dev/sda1 (ext4 mounted read-write at /).

This operation could silently destroy your data.  Are you sure (y/N)? y
Creating temporary file (13647400 KB)..
Syncing disks..
Beginning TRIM operations..
get_trimlist=/sbin/hdparm --fibmap WIPER_TMPFILE.9689

trimming 27294800 sectors from 462 ranges
Removing temporary file..
Syncing disks..

However if I run it again, it shows the same number of sectors/ranges need to be trimmed, and reports success again. I get exactly the same thing every time. It doesn't look like the sectors are ever deleted/freed. Reading them still shows the same data.

Curious if anyone else has got it to work.

  • If you added the discard option to fstab and it is still not working its probably a bug in the alpha. You should file a bug report.
    – Uli
    Feb 6, 2011 at 22:55
  • I just tested this in natty (following these instruction: askubuntu.com/questions/18903/how-to-enable-trim) and its working even better in natty, TRIM is almost instantaneous.
    – Uli
    Apr 27, 2011 at 19:21
  • It's possible you have an SSD that does not support TRIM - quite a few of the earlier SSDs did not support TRIM. May 12, 2012 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.