You are not logged in.

#1 2023-02-14 12:09:46

LithoUser
Member
Registered: 2016-11-17
Posts: 154

[SOLVED] Should I use TRIM?

Hello,

I wonder if I should use TRIM on my SSD.

I have three drives:
- one SSD (/dev/sda) with my /boot and /root folders;
- two HDDs (/dev/sdb and /dev/sdc) with my (encrypted) /home folder.

According to the wiki here, `lsblk --discard` shows that my SSD supports TRIM:

NAME                         DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda                                 0      512B       2G         0
└─sda1                              0      512B       2G         0
sdb                                 0        0B       0B         0
└─sdb1                              0        0B       0B         0
  └─old_hdd                         0        0B       0B         0
    ├─vgroup-lv_swap                0        0B       0B         0
    └─vgroup-lv_home                0        0B       0B         0
sdc                                 0        0B       0B         0
└─sdc1                              0        0B       0B         0
  └─new_hdd                         0        0B       0B         0
    ├─vgroup_new-lv_swap_new        0        0B       0B         0
    └─vgroup_new-lv_home_new        0        0B       0B         0

The problem is: I've installed my Arch Linux system 3 years ago, but only recently have I discovered this `TRIM` thing (thanks to this reddit post)... and I've never used it yet.

So my questions are:

1. Is it too late or not to use `TRIM` on my disk?
2. What would the correct command be?
3. Should I also enable `fstrim.timer` systemd unit file?

Thanks in advance for your help!

Last edited by LithoUser (2023-02-14 17:36:03)

Offline

#2 2023-02-14 12:22:43

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 22,910

Re: [SOLVED] Should I use TRIM?

It's never "too late" but also not strictly necessary, you can do so if you want. As for the command see the fstrim manpage. If the partition in question is listed in your fstab you can do

fstrim -A

as root or you can pass a mount point directly. Whether or not you want to enable the timer is also up to you. From anecdote I have it disabled on a laptop of mine because there used to be a situation where the timer kicking in during boot would significantly delay boot time but afaik this has been fixed in later service versions to always start a bit later. It's enabled on the desktop and hasn't caused any notable issues

Offline

#3 2023-02-14 12:39:34

frostschutz
Member
Registered: 2013-11-15
Posts: 1,459

Re: [SOLVED] Should I use TRIM?

Set up backups first. ;-)

If you're looking for performance gains, you should relocate your /home to SSD instead. Keeping movies and other clunky stuff on HDD is fine, but the everyday stuff (config files, browser caches, etc.) should be on SSD.

There are tons of small files in your home and if every file access has to wait for HDD access times then that will harm your perceived performance. SSD for / root only is nearly useless.

Offline

#4 2023-02-14 14:50:04

LithoUser
Member
Registered: 2016-11-17
Posts: 154

Re: [SOLVED] Should I use TRIM?

Thank you very much V1del and frostschutz for your explanations and advice!

V1del wrote:

As for the command see the fstrim manpage.

The reason I was asking is that I'm confused, I think: I thought there was a "trim" command, but if I understand correctly, there isn't; you can only run a *periodic* "trim" action on an SSD through the "fstrim" service of systemd... Is that it?

frostschutz wrote:

Set up backups first. ;-)

Already done, for several years (thanks to rsync).

frostschutz wrote:

If you're looking for performance gains

I'm not! I just thought that it was good maintenance (more or less like the Microsoft Windows disk defragmenter?) But since V1del answered that it's "not strictly necessary", I'm wondering if I'm right... May I see serious slowdowns in a few years if I don't enable fstrim? Could it cause other problems? (e.g. shorten the lifetime of my SSD?)

frostschutz wrote:

the everyday stuff (config files, browser caches, etc.) should be on SSD.

You're right; maybe I should rethink the organization of my partitions. However, I already place my Firefox profile to RAM, among other things... The rest that I use (st terminal, vim, etc.) opens nearly instantaneously. I'd make an exception for LibreOffice (about 4 seconds to be opened and ready)... but I think I can live with it. Besides, I don't have as much time as I'd like to spend on my beloved dotfiles wink

Last edited by LithoUser (2023-02-14 14:52:24)

Offline

#5 2023-02-14 16:37:54

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 22,910

Re: [SOLVED] Should I use TRIM?

You can in theory run the low level TRIM command as well but that will ultimately have the same end effect as running fstrim on the filesystem (... assuming it's spanning the entire disk) and letting the kernel handle things. You can run fstrim as a standalone command whenever you feel like, the timer/service is only provided as a convenience to run the fstrim command once a week. It's hard to quantify the benefits of TRIM and it's highly dependant on your SSD implementation. It should generally be safe and AFAIK be a good measure to do occasionally, but you don't know what bugs might lurk in any given firmware implementation. But as seen from the reddit thread it did at least help someone.

Offline

#6 2023-02-14 17:35:48

LithoUser
Member
Registered: 2016-11-17
Posts: 154

Re: [SOLVED] Should I use TRIM?

OK, thank you very much!

I've run it as a single command:

sudo fstrim -v /

It performed in about 30 seconds, and then displayed a message about 71GB that have been reduced (don't know what the english word would be, my message was in french). So it seems like it's worked correctly, and I think I'll enable the timer.

Thank you very much for your help, and have a nice day!

Offline

Board footer

Powered by FluxBB