Trim command (TRIM) helps keep your solid-state drive (SSD) at its full speed. If you find your SSD slowed down after a while of using, TRIM may help you make SSD always fast.
Because low-level operation of SSDs differs significantly from hard drives, the typical way in which operating systems handle operations like deletes and formats resulted in unanticipated progressive performance degradation of write operations on SSDs. Trimming enables the SSD to handle garbage collection overhead, which would otherwise significantly slow down future write operations to the involved blocks, in advance.
See more about TRIM on the Wiki page
UPDATE: Ubuntu 14.04 Trusty will have TRIM enabled by default.
To get started, press Ctrl+Alt+T on keyboard to open terminal. When it opens, follow steps below:
1. Check out if you have an SSD:
cat /sys/block/sda/queue/rotational
If you got 0 it’s a SSD. If the output was 1 it’s a HDD.
2. Even if you have an SSD not all of them support TRIM. To find out if yours does run:
sudo hdparm -I /dev/sda | grep "TRIM supported"
If what you get back is this:
Data Set Management TRIM supported
Then you are all good to go. If there’s no output, your SSD doesn’t support TRIM.
3. Next run:
sudo fstrim -v /
You should see an output that looks something like this:
/: 87781376 bytes were trimmed
4. If everything went OK it’s time to make a CRON job so fstrim run’s once a day.
To do this run:
gksudo gedit /etc/cron.daily/trim
Copy and paste below lines and save it.
#!/bin/sh
LOG=/var/log/trim.log
echo “*** $(date -R) ***” >> $LOG
fstrim -v / >> $LOG
fstrim -v /home >> $LOG
Finally make it executable:
sudo chmod +x /etc/cron.daily/trim
That’s it. You now have TRIM enabled.
via: pinguyos forum
If I were you, I woudn’t do the trim command once a day because it spents write cycles unnecessarily. For a normal use, once a week is quite enough, because the SSD takes long time to decrease its performance because of the lack of memory pages.
The other way is putting the argument “discard” in the SSD line at /etc/fstab and leave it to the SSD native controller.
I added “discard” in fstab in Ubuntu 14.04 beta 2. But I still can fstrim -v / about 12 GB. Why? No use of “discard” in fstab? New ADATA 128GB SSD
@kaji331, Ubuntu 14.04 will have the TRIM enabled by default: http://www.omgubuntu.co.uk/2013/12/trim-ssd-support-enabled-ubuntu-14-04
Thanks again. I saw the pages of stackover flow about manually trim SSD in Linux and the script in cron.weekly of Ubuntu 14.04 beta2. Unfortunately, although Ubuntu 14.04 uses fstrim automatically, fstrim has lost data bug in high load I/O status except Intel and Samsung SSD. I have to add “discard” in fstab, manually…ADATA.
I wrote another cron job solution called SSDcronTRIM. My idea was to write a script which automatically recognized based on the used disk space, how often the disk has to be trimmed (monthly, weekly, daily, hourly). In my opinion this is the best balance between an “only trim when it is necessary” and an “fire and forget” solution like discard in fstab. You can find the script and instructions on github: http://chmatse.github.io/SSDcronTRIM/
Whats the code to make it every 2, or 3 days instead of one?