ssd trim on raspberry pi


It took a few minutes of googling around to find instructions for this that work, so I’m going to put some very specific ones here for my future reference.

I’ve been attaching SSDs to my RPi 4’s and finding good cables has turned out to be more of a challenge because of lack of proper UASP and Trim support for the controllers in Linux. The majority of the difficulty is finding info on what controller is being used by the adapter and then determining if it uses the UAS driver AND support Trim. I ended up going with these cables from Startech (they’re half the price if you order on Amazon). There’s a firmware update available that adds Trim support.

Once the firmware is updated, there’s just a little bit of config to be done in Linux:

Identify the vendor (174c) and product (55aa) IDs:

pi@raspberrypi:~$ lsusb
Bus 002 Device 002: ID 174c:55aa ASMedia Technology Inc. Name: ASM1051E SATA 6Gb/s bridge, ASM1053E SATA 6Gb/s bridge, ASM1153 SATA 3Gb/s bridge, ASM1153E SATA 6Gb/s bridge

Create a udev rule to change the provisioning mode to “unmap”:

echo 'ACTION=="add|change", ATTRS{idVendor}=="174c", ATTRS{idProduct}=="55aa", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"' | sudo tee -a /etc/udev/rules.d/50-usb-ssd-trim.rules

Enable the Trim timer service:

sudo systemctl enable fstrim.timer

I reboot after this and do some validation checks:

UAS driver:

pi@raspberrypi:~$ lsusb -t
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
|__ Port 2: Dev 2, If 0, Class=Mass Storage, Driver=uas, 5000M

Trim works:

pi@raspberrypi:~$ sudo fstrim -v /
/: 187.4 MiB (196468736 bytes) trimmed

That’s it.


Leave a Reply

Your email address will not be published. Required fields are marked *