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 three ways to perform TRIM, manual, scheduled, and automatic:
In Ubuntu this can be performed with
however it is not needed when scheduled or automatic TRIM are enabled, as detailed in the sections below.
Note: For Ubuntu 11.04 and earlier systems, fstrim is not available so you have to use
This is the currently recomended method, and is planed to be activated per default for Ubuntu 14.04. Here's how to activate it manually in older versions of ubuntu (11.10 to 13.10):
Create a daily CRON job script file:
Paste the following code in the file, then save and close the file:
Note that the above assumes that only your root filesystem
Make the script executable:
And finally test it:
If you see no errors, your cron job should be working fine.
Automatic TRIM (Deprecated, Slow)
Automatic TRIM has been supported since Ubuntu 10.10 (kernel 2.6.33) with the EXT4 file system. However, sending TRIM commands to the SSD in real-time - after every delete - has been recognized to make deletion much slower than usual on some drives. Therefore a daily scheduled TRIM via a cron job (described above) is recomended.
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.
|show 1 more comment|
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
How to Activate TRIM on LUKS Encrypted Partitions in Ubuntu & Debian
This step by step walkthrough will let you take advantage of the TRIM technology for your encrypted SSD partitions for cryptsetup 1.4 or higher and kernel 3.1 or higher. This leads to a hassle-free SSD experience because
Notebook with SSD as the single drive, Linux installed in single ext4 LVM root partition with LVM swap partition, both over LUKS encrypted logical partition.
TRIM is activated. Enjoy your hassle-free SSD!
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.
I tried doing the automatic option. However, I now cannot boot into my computer. I get the error: press "s" to mount and "M" to do manually. And I cannot do anything from there. I have been trying all day to try and fix this file, but am not finding anything that works.
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.