NVMe SSD TRIM Settings: Do I need to do anything after moving from SD Card to NVMe SSD?

Hello,

I just transferred my root and boot volumes from an SD Card to an NVMe SSD. Everything’s working. :slight_smile:

I notice that TRIM is available, but:

  1. I can’t tell if it’s enabled.
  2. I don’t know how to enable it.
  3. I don’t know if I need to enable it.

Any suggestions would be appreciated. Thanks!

2 Likes

That is up to the filesystem you choose to use. This link should prove helpful.

With the command

systemctl status fstrim.timer

you can see if the timer is enabled wich triggers the service that does the actual trimming.

1 Like

Thanks!

That was indeed helpful. It appears, somehow, TRIM is not supported on my SSD, at least according to the OS.

~]$ sudo hdparm -I /dev/sda | grep TRIM
[sudo] password for panoptitom:
SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00


Apparently DISC-GRAN and DISC-MAX should have non-zero values on a TRIM-enabled drive?

Yet, Sabrent 500GB Rocket Nvme PCIe 4.0 M.2 2280 Internal SSD Solid State Drive (SB-ROCKET-NVMe4-500) | SB-ROCKET-NVMe4-500 clearly indicates this drive supports TRIM.

EDIT: The interface board DOES support TRIM. https://raspberrypiwiki.com/index.php?title=X872&mobileaction=toggle_view_desktop

Am I missing something? Am I going to ruin my SSD operating it without TRIM?

1 Like

You are running the ssd as an external drive right?

Yeah. I mean, it’s plugged into a USB 3 port.

I’ll check out that link. Thanks!

Followed those directions (thanks, @Darksky! ). Ran it once and it trimmed several hundred MBs.

Enabled fstimer.service. Now I’ve got this:

DISC-GRAN and DISC-MAX are just gone now, and hdparm -I isn’t exposing TRIM info, so I’m a bit concerned. But I know the drive supports TRIM, so it shouldn’t be damaged in any case.

Right?

Take a look at the Conclusion.

So no. Don’t even be concerned if you can not get trim to work. Simply overprovision the SSD. Meaning, when you partition it, do not allocate all of the space. How much to not allocate is up to you. This allows for greater wear leveling, extending the life of the SSD. And after all, that is the most important thing. You could use a COW filesystem, I use f2fs myself. But I am trying to warm up to btrfs.

Hi,

On my side I use the command
sudo fstrim --all
it launch the trim and give you a negative answer for some disc when it is not possible.

No negatives answer on my arm devices… I hope it works

1 Like

@Darksky’s tutorial worked for me, and it trimmed several hundred MBs when it ran. I’ll know in a week if the timer service works, but I’m not too worried that it won’t.

At this point I’m more concerned by the super-bright blue blinking light on the SSD interface board. Sleeping in the same room as the Pi is now slightly more aggravating than it was before. :stuck_out_tongue:

Today I had messages that fstrim failed (fstrim.service). I had assumed the mount option ssd incorporated enabling trim support, but it does not.

Make sure to add a discard to the fstab mount options:
$ /etc/fstab

UUID=92DA-BDF9                                  /boot                   vfat    defaults,noatime,discard,nofail                                                                         0       0
UUID=2b382e06-d18c-471c-81cf-493b76bca157       /                       btrfs   defaults,noatime,ssd,discard=async,compress-force=zstd,subvol=@                                         0       0

Note: vfat does not seem to support discard=async, so just discard will have to do.

1 Like