Enable Trim for SSDs? Topic is solved

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Post Reply
threefoursixeight
Posts: 17
Joined: Wed Oct 30, 2019 3:55 am

Enable Trim for SSDs?

Post by threefoursixeight »

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!
User avatar
Joulinar
Posts: 2074
Joined: Sat Nov 16, 2019 12:49 am

Re: Enable Trim for SSDs?

Post by Joulinar »

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
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
threefoursixeight
Posts: 17
Joined: Wed Oct 30, 2019 3:55 am

Re: Enable Trim for SSDs?

Post by threefoursixeight »

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:

Code: Select all

 #! /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?
User avatar
Joulinar
Posts: 2074
Joined: Sat Nov 16, 2019 12:49 am

Re: Enable Trim for SSDs?

Post by Joulinar »

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:
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
threefoursixeight
Posts: 17
Joined: Wed Oct 30, 2019 3:55 am

Re: Enable Trim for SSDs?

Post by threefoursixeight »

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 😛 I’m seeing some conflicting information about whether my SSD supports TRIM.
User avatar
MichaIng
Site Admin
Posts: 2294
Joined: Sat Nov 18, 2017 6:21 pm

Re: Enable Trim for SSDs?

Post by MichaIng »

Hey guys, found a german thread about this, in case translation could help: https://forum-raspberrypi.de/forum/thre ... 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.
Post Reply