Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Solid State Drives and TRIM in Debian

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Solid State Drives and TRIM in Debian

#1 Post by Head_on_a_Stick »

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 ... l-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
deadbang

User avatar
phenest
Posts: 1702
Joined: 2010-03-09 09:38
Location: The Matrix

Re: Solid State Drives and TRIM in Debian

#2 Post by phenest »

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?
ASRock H77 Pro4-M i7 3770K - 32GB RAM - Pioneer BDR-209D

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Solid State Drives and TRIM in Debian

#3 Post by Head_on_a_Stick »

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
deadbang

User avatar
kalle123
Posts: 346
Joined: 2015-03-21 11:17
Location: Rhineland - Germany
Has thanked: 4 times
Been thanked: 11 times

Re: Solid State Drives and TRIM in Debian

#4 Post by kalle123 »

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: 346
Joined: 2015-03-21 11:17
Location: Rhineland - Germany
Has thanked: 4 times
Been thanked: 11 times

Re: Solid State Drives and TRIM in Debian

#5 Post by kalle123 »

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)

Post Reply