I know that the Linux kernel supports TRIM as of version 2.6.33, so there should be TRIM support in ubuntu.
Is TRIM enabled by default or do I need to change some settings or install additional software for it to work? If so, how?
There are two ways to perform TRIM, manual and automatic:
In Ubuntu this can be performed with
however is not needed when automatic TRIM is enabled, as detailed in Automatic section below.
Note: For Ubuntu 11.04 and earlier systems, fstrim is not available so you have to use
Automatic TRIM has been supported since Ubuntu 10.10 (kernel 2.6.33) with the EXT4 file system.
To enable automatic TRIM on a drive or partition, they need to be mounted with the
Close and save fstab, then reboot and automatic TRIM should now be working.
Testing automatic TRIM
To test if TRIM is working issue the following commands (source):
From the output copy the number under
Run the following but replace
the output should be a long string of characters for those sectors
If you get only zeros then automatic TRIM is working. However if after removing the file the sectors are still not empty then wait a while and run the command again.
Note that if you are using encryption the solutions posted here so far won't help you, because you need to enable TRIM support in the encryption layer as well. This can be done with kernel versions 3.1+ and cryptsetup versions 1.4+, both of which are included in Ubuntu 12.04.
Find my guide on setting TRIM up for LUKS encrypted partitions here
I just followed these instructions on webupd8 which gives some really good options :-)
I tried the option for automatic trim as described above in "Automatic TRIM" but found that setting up a daily cron worked alot better with my setup.
This question is protected to prevent "thanks!", "me too!", or spam answers by new users. To answer it, you must have earned at least 10 reputation on this site.