Enable Trim for SSDs?

Hi everyone,

I currently have dietpi on a raspberry pi 4, with boot on an SD card and then the rest of the OS on an external SSD connected over USB.

My question is, do I need to enable trim for the SSD, or is that enabled by default? If it isn’t, how can I go about enabling trim?

Thanks!

Hi,

I don’t think TRIM is enabled by default. Some further information about SSD Optimization and how to use TRIM could be found at this page.

https://wiki.debian.org/SSDOptimization

Thank you, that was good reading. It looks like the more recommended method is to run fstrim weekly as a cron job.

There’s an example script they showed that runs fstrim for /, /boot, and /home:

 #! /bin/sh
for mount in / /boot /home; do
	fstrim $mount
done

However, I’m assuming I don’t want to do trim on the sd card which is /boot.

Could I simply remove /boot from the loop’s parameters, or will “/“ still encompass /boot?

Unfortunately I’m hundreds of kilometer far away from my physical DietPi installations. Therefore I can’t check it. But usually / should be located on your external SSD. Only /boot should be located on your SD card still. But you could check it using dietpi-drive_manager. There you will see the mount point of your external SSD. At least I hope :roll_eyes:

Gotcha! Well I appreciate you helping me even though you’re far away!

I think I’ll need to do more research to make sure my SSD actually supports TRIM before I go any further and cause data loss :stuck_out_tongue: I’m seeing some conflicting information about whether my SSD supports TRIM.

Hey guys, found a german thread about this, in case translation could help: https://forum-raspberrypi.de/forum/thread/36428-ssd-am-raspberry-pi-3-trim/
In short:

  • TRIM is a SATA command, hence it cannot be done for USB-attached SSDs.
  • Some SSD controllers run TRIM internally, but not change to force that from the OS.

There seem to be some hacks possible, e.g. create a file that fits exactly into empty space with zeros, then remove it, but nothing I would recommend.