Solid State Drives and TRIM in Debian

Share your own howto's etc. Not for support questions!

Solid State Drives and TRIM in Debian

Postby Head_on_a_Stick » 2016-12-28 15:45

For users with solid state storage devices, TRIM can be used to inform the drive which storage blocks are no longer in use and can be wiped internally, thus preventing performance hits from spurious over-writes and write amplification.

Verify that your device supports this operation with:
Code: Select all
lsblk -D

Then check the DISC-GRAN and DISC-MAX columns -- non-zero values indicate that TRIM can be used.

Whilst it is possible to apply TRIM with the discard filesystem option in /etc/fstab, this can cause a performance degradation because the blocks are discarded with every deletion:

https://patrick-nagel.net/blog/archives/337

https://kparal.wordpress.com/2013/05/10/impact-of-discard-mount-option-on-intel-525-ssd/

Also, with discard enabled, any deleted data is lost completely and instantly and so recovery utilities such as extundelete will not work.

The recommended alternative to this is to apply TRIM periodically using the `fstrim` command.

In Debian systems, there is a systemd .timer unit that can be enabled with:
Code: Select all
# cp /usr/share/doc/util-linux/examples/fstrim.{timer,service} /etc/systemd/system
# systemctl enable fstrim.timer

This will then run `fstrim -a` automatically once a week.

To check the status of the .timer, use:
Code: Select all
systemctl list-timers

The .timer also integrates with the systemd journal; to view the relevant entries, use:
Code: Select all
# journalctl -u fstrim.timer
"Only the mediocre are always at their best." — Jean Giraudoux
User avatar
Head_on_a_Stick
 
Posts: 6674
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Solid State Drives and TRIM in Debian

Postby phenest » 2016-12-28 18:41

I consider myself a fairly heavy user when it comes to modifying/deleting files by way of video editing, C programming, photo editing, web browsing, etc, and I've seen no perceivable performance change with or without the discard option. In fact, I'm happy to use neither discard nor fstrim, because the SSD's built-in garbage collection will do the job as it's needed. Crucial's SSDs will do garbage collection during idle periods, so it's unnoticeable.

Also, with modern SSD's, there is no need to be concerned with how full the drive is getting because there is enough over-provisioning of space for it to be a non-issue.

EDIT: Incidentally, I realise the thread is about TRIM but, is it worth mentioning noatime & nodiratime mount options?
NEC Spirit 550 P4 3.8GHz HT - 2GB RAM - nVidia 7600GT - Pioneer BDR-209DBK
ASUS Sabertooth P67 i7 3770K - 32GB RAM - 2x nVidia 660GTX SLI'd
User avatar
phenest
 
Posts: 1571
Joined: 2010-03-09 09:38
Location: The Matrix

Re: Solid State Drives and TRIM in Debian

Postby Head_on_a_Stick » 2016-12-28 23:16

phenest wrote:I'm happy to use neither discard nor fstrim, because the SSD's built-in garbage collection will do the job as it's needed. Crucial's SSDs will do garbage collection during idle periods, so it's unnoticeable.

Also, with modern SSD's, there is no need to be concerned with how full the drive is getting because there is enough over-provisioning of space for it to be a non-issue.

This is fair comment.

Slightly related: I have an SSD in my ThinkPad that runs OpenBSD and their filesystem offers no (userspace) TRIM options at all but the developers seem to suggest that any management is automagical and mostly at the hardware level:

http://www.tedunangst.com/flak/post/les ... about-TRIM

is it worth mentioning noatime & nodiratime mount options?

No, not even slightly :mrgreen:

The default relatime option should be perfectly sufficient and concerns in respect of drive longevity are largely relics of the past with modern production techniques.

http://techreport.com/review/27909/the- ... e-all-dead
"Only the mediocre are always at their best." — Jean Giraudoux
User avatar
Head_on_a_Stick
 
Posts: 6674
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Solid State Drives and TRIM in Debian

Postby kalle123 » 2017-07-02 08:34

Head_on_a_Stick wrote:This will then run `fstrim -a` automatically once a week.


Is that fixed or can this be changed to daily, monthly and will it work?

br
User avatar
kalle123
 
Posts: 198
Joined: 2015-03-21 11:17
Location: Rhineland - Germany

Re: Solid State Drives and TRIM in Debian

Postby kalle123 » 2017-07-03 09:23

Seems to work. Switched to monthly yesterday.

$ sudo systemctl list-timers --all
[sudo] Passwort für kalle:
NEXT LEFT LAST
Mon 2017-07-03 13:04:37 CEST 55min left Mon 2017-07-03 12:00:41 CEST
Mon 2017-07-03 19:36:20 CEST 7h left Mon 2017-07-03 07:09:54 CEST
Tue 2017-07-04 06:34:41 CEST 18h left Mon 2017-07-03 07:09:54 CEST
Tue 2017-07-04 11:38:50 CEST 23h left Mon 2017-07-03 11:38:50 CEST
Tue 2017-08-01 00:00:00 CEST 4 weeks 0 days left Sun 2017-07-02 05:54:58 CEST

5 timers listed.
lines 1-8/8 (END)
User avatar
kalle123
 
Posts: 198
Joined: 2015-03-21 11:17
Location: Rhineland - Germany


Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable