Status of TRIM on Linux?

VirtualLarry

No Lifer
Aug 25, 2001
56,572
10,208
126
I heard that Linux only enables TRIM on certain whitelisted drives, instead of any drive that reports that it is supported.
 

F1shF4t

Golden Member
Oct 18, 2005
1,583
1
71
I just run fstrim every month, but would be interesting to know for sure.
 

Essence_of_War

Platinum Member
Feb 21, 2013
2,650
4
81
I heard that Linux only enables TRIM on certain whitelisted drives, instead of any drive that reports that it is supported.

On the most recent distros, I think TRIM is enabled by default on drives that support it. You can check your fstab to be sure by running:

Code:
grep discard /etc/fstab

you should see something like:

Code:
/dev/sdaX / ext4 defaults,noatime,[U][B]discard [/B][/U]

for a linux installation with trim enabled. I think you should be able to add the "discard" option manually for any drive that supports TRIM that doesn't have it enabled by default.
 

H54

Member
Jan 16, 2011
187
0
71
There is a fair amount of info on the net that claims adding discard to fstab noticeably affect performance.

If you're using systemd:
Code:
sudo systemctl enable fstrim.timer && sudo systemctl start fstrim.timer

I tested disk performance before and after:
Code:
sudo hdparm -t /dev/sdx
 

H54

Member
Jan 16, 2011
187
0
71
What did you find?


Whoops, somehow the rest of the post was cut off.

I ran several tests before and after the change. Consistently, reads were substantially higher.

Code:
run 1
 Timing buffered disk reads: 1478 MB in  3.00 seconds = 492.20 MB/sec

run 2
 Timing buffered disk reads: 1492 MB in  3.00 seconds = 497.04 MB/sec

run 3
 Timing buffered disk reads: 1496 MB in  3.00 seconds = 498.66 MB/sec

They used to be in the low to mid 400s (420-430, typically).
 

Elixer

Lifer
May 7, 2002
10,371
762
126
I have been doing fstrim -v / monthly on the work laptop, and this time around, it reported back 56GB trimmed.
For a year, the average is around 20GB trimmed.
This SSD has 256GB, haven't seen any slow downs on it, so, I am not even sure it is worth it to add fstrim to a cron job to execute daily/weekly instead of monthly.

I am hesitant to add discard to fstab from all the bad stories about it.