I have a couple Argon One M.2 v.1 (with micro hdmi ports) cases and they lacked trim support with my Kingston A400 SSDs. A little google-foo turned up some good links, here, here and the firmware from here.
After working through the links, I managed to get trim support working. However, on reboot, the discard_max_bytes kept being set to the same value as discard_max_hw_bytes and I would get an error when attempting to run fstrim -v /.
fstrim: /: FITRIM ioctl failed: Remote I/O error
So I modified the suggested udev rule which resolves the issue:
#For some reason this rule does not work... so second runs a command
#KERNEL=="sda", SUBSYSTEM=="block", ATTR{queue/discard_max_bytes}="2147450880"
KERNEL=="sda", SUBSYSTEM=="block", RUN+="/bin/sh -c 'echo 2147450880 > /sys/block/sda/queue/discard_max_bytes'"
ACTION=="add|change", ATTRS{idVendor}=="174c", ATTRS{idProduct}=="55aa", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"
Anyone know why the first rule does not work?
Edit: It appears the newer M.2 does have a version of firmware that supports trim but you still need to configure it.
Edit 2: The same value ( 2147450880 ) is used with the Samsung 860 EVO M.2 SATA
I’ve spent days trying to get this to work, Thank you so much for this!
Just a slightly more generic version, I use both USB3 ports on the Pi for storage, so this targets the argon40 specifically, otherwise it sometimes tries to apply the discard_max_bytes to my hard drive.
I hope you don’t mind, I’m going to mention this post elsewhere I found bad advice on this topic. I have a feeling a lot of people think they have trim when really they don’t, because discard_max_bytes is not persistent.