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
“Controlling complexity is the essence of computer programming."Brian Kernighan

Please read before posting How to report a problem
User avatar
Head_on_a_Stick
 
Posts: 6489
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?
Dell XPS 17 L702X i7 2860QM 2.5GHz - 32GB RAM - 4G WWAN - Pioneer TD05-BDR
NEC Spirit 550 P4 3.8GHz HT - 2GB RAM - nVidia 7600GT - Pioneer BDR-209DBK
ASUS P8P67 EVO i7 3770K - 32GB RAM - 2x nVidia 660GTX SLI'd
User avatar
phenest
 
Posts: 1440
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
“Controlling complexity is the essence of computer programming."Brian Kernighan

Please read before posting How to report a problem
User avatar
Head_on_a_Stick
 
Posts: 6489
Joined: 2014-06-01 17:46
Location: /dev/chair


Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable