I am currently trying to find out how to trim with my new TP and was wondering about the difference of manual/online trimming.

Here is my setup:

ThinkPad T430s with SSD Samsung 830, 128GB and Xubuntu 12.10, here are some outputs to check if trim will work on my system (got these from here: http://wiki.ubuntuusers.de/SSD/TRIM)

root@eike-tp:~# sudo hdparm -I /dev/sda | grep -i TRIM
   *    Data Set Management TRIM supported (limit 8 blocks)

First, I tried the online trimming: How to enable TRIM?

my fstab with discard inserted:

UUID=d6c49c17-a4f1-466c-9f7e-896c20db3bba /  ext4  discard,noatime,errors=remount-ro  0  1
# swap was on /dev/sda5 during installation
UUID=a0322f5f-c6c1-4896-863f-668f0638d8cf none  swap  sw  0   0
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0

I tried to test if it works (but I don't get any zeroes when I try it with /dev/sda), but found out that this method is only possible with SSD type 2 and I seem to have type 3. So I don't know if it works or not.

The Ubuntuwiki (first link) recommends manual trimming, so I set up a daily cronjob instead of discard:

echo "*** $(date -R) ***" >> $LOG
fstrim -v / >> $LOG

the wiki article suggests weekly or daily. Now to my questions:

How often executes the automated trim? How often is recommended? Online vs. manual trimming?

Thank you for your help

4 Answers 4


The difference between automatic and manual trim is that automatic trim (using the discard mount option) trims freed blocks on sync after any file is deleted, whereas manual trim (using fstrim) trims all the free space at once.


One way you could test whether automatic trim is working would be to create and delete a large file:

user@host:/somewhere$ dd if=/dev/urandom bs=1M count=100 of=bigfile
user@host:/somewhere$ sync
user@host:/somewhere$ rm bigfile
user@host:/somewhere$ sync

If automatic discard is working, manually trimming again won't trim many blocks, since they should have already been trimmed. Run sudo discard -v on your filesystem and see how many blocks are trimmed.


As for which is recommended: In my experience, automatic trim kills performance. However, this is probably hardware-dependent; it may be fine on your drive.

If you're using manual trim, as for how often, think about the rate at which you write data in your typical workload, compared to the amount of free space on your SSD. You want to trim sufficiently often, before your disk fills up with deleted data. If your SSD is mostly free space or your disk workload is light, trimming occasionally (weekly or even longer) should suffice. If your SSD is mostly full or you e.g. edit video files frequently, you'll need to trim more often.


I'm no storage engineer and I have related worries of my own, but I can make a possibly useful suggestion on scheduling. I'm pretty confident TRIM doesn't cause any worrisome wear on the SSD. It's just housekeeping that your disk will have to undergo eventually, before it can start recycling blocks. The best schedule for batch TRIMming would depend on usage; a function of writing frequency and free space, I should think. That in mind, I would unplug the cron job and fstrim -v by hand for several days.

The trick I think is to craft a schedule where batch TRIM prepares the SSD for writing before used blocks have to be recycled in order to fulfill a normal write operation, thus hurting performance. Wait 24 hours and fstrim. If it claims to have trimmed far fewer blocks than were free space, you're probably well served batch TRIMming less often than that.


I prepared fstrim demon https://github.com/dobek/fstrimDemon

It seems to be more reliable to execute fstrim based on up time then cron table. Have fun.


I trim my SSD on every boot. I made a sh file that is called 20 seconds after startup. I opted to display the output from fstrim in a system notification instead of a log file.

first create the trim.sh file in your ~/bin directory

#! /bin/sh
notify-send "TRIM" "$(sudo fstrim -v /)"

Now we need to give the user privileges to run fstrim so we don't need to enter a password. Open your sudoers file with visudo and append the following line:

yourusername  ALL=(ALL) NOPASSWD: /sbin/fstrim

If you include your home/yourusername/bin folder to your $PATH you also can trim manually in the terminal with the command 'trim' without the need for a password.

Now you can add your script to the start up applications and specify a delay. You need to logout/login again so your new sudoers entry get loaded.

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.