Note: The following steps will not work if you have encrypted your partition.
First, we have to make sure that the SSD in your computer supports TRIM. In Ubuntu, open a terminal and type: If Ubuntu is not installed in the first partition of the SSD, change “sda” to reflect the partition where Ubuntu is residing. Scroll down the list till you see the “Enabled Supported:” section. Scroll down further and if you see something like “Data Set Management TRIM supported (limit 4 blocks)“, then TRIM is supported for your SSD.
Next, we need to test if the TRIM function is working in Ubuntu. In the terminal, type: This will clean up the root partition of the SSD. If successful, you should see something like this:
Lastly, we will set a cron job for the OS to send the TRIM command once everyday. Paste the following code into the blank area: If your HOME directory in located on another partition, you can add additional line to the end of the above code: If you want to save the output to a log file, you can use the following code instead: Save (Ctrl + o) and exit (Ctrl + x). Now, make the cron job executable: That’s it. Image credit: My SSD