Pi 3B+ SDD no UASP but TRIM possible

Apparently Pi 3B+ have no UASP support :slightly_frowning_face:

Means no SSD TRIM.

https://www.jeffgeerling.com/blog/2020/uasp-makes-raspberry-pi-4-disk-io-50-faster

TRIM should be also possible without UASP

https://www.jeffgeerling.com/blog/2020/enabling-trim-on-external-ssd-on-raspberry-pi

https://wiki.archlinux.org/title/Solid_state_drive#External_SSD_with_TRIM_support

It might still depend on controller.

I have Kingston A400120G and VL711 controller and does not work.

Kingston website says A400 supports TRIM.

V

Did you follow the discription in the link to the archlinux wiki posted to get TRIM working?

This post also might help you:

I got this actually working yesterday. I did the steps found on the Arch Linux wiki, but it did not mention setting discard_max_bytes for the disk. Setting this to the correct value (and persisting it using an udev rule) has TRIM fully working for me on my Pi 3B

I’m trying no joy. Thanks BTW.

I checked my controller which is via VL711 say support UASP and the SSD is Kingston A400 120G which also say supports TRIM

https://www.via-labs.com/product_show.php?id=44

Kingston cant update firmware… got S3501103 - KSM says no updated firmware.
accoring to link
Specifications of KINGSTON SA400S37120G Drive with S3501103 Firmware it says Phison controller.

Run Phison tools also says unable to find SSD to update.

Anyways… just relied on manufacturer docs that controller and SSD supports trim.

I’m trying on Linux Lite live CD on a laptop to see if I can test TRIM.

sg_vpd -p bl /dev/sdb

Maximum unmap LBA count: 4194240
sg_readcap -l /dev/sda

Logical block length=512 bytes 
echo $((4194240*512))
2147450880

set discard_max_bytes has been set.

cat /sys/block/sdb/device/scsi_disk/*/provisioning_mode
unmap

So umap has been set.

when I run fstrim -v / says the discard operation not supported.

I also tried blkdicard to wipe the SSD but got

blkdiscard: cannot open /dev/sdb2: Device or resource busy

Not sure how to enable in HAOS as very limited commands.

I opened port 2222 to connect to HAOS rather than container.

Got it working…

lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0    7:0    0   1.9G  1 loop /rofs
sdb      8:16   0 111.8G  0 disk 
├─sdb1   8:17   0    50M  0 part 
├─sdb2   8:18   0 111.2G  0 part /media/linux/A0B89657B8962C32
└─sdb3   8:19   0   508M  0 part 
sdc      8:32   1  28.9G  0 disk 
└─sdc1   8:33   1  28.9G  0 part /cdrom
sr0     11:0    1  1024M  0 rom  

fstrim -v /media/linux/A0B89657B8962C32
/media/linux/A0B89657B8962C32: 85.1 GiB (91333144576 bytes) trimmed

Moving on…

Now how to do on HAOS :frowning:

Lol… I was able to run the blkdiscard but forgot to document what I did.

I run hdparm, wipefs and at onepoint blkdiscard worked.

https://utcc.utoronto.ca/~cks/space/blog/linux/ErasingSSDsWithBlkdiscard?showcomments

dd if=/dev/zero of=/dev/sdX bs=1024k count=128; sync

Sorted out , TRIM now working on HAOS.

https://www.jeffgeerling.com/blog/2020/enabling-trim-on-external-ssd-on-raspberry-pi

1 Like

Awesome! Now you might want to correct the title of the thread to something like “Pi 3B+ SSD no UASP but TRIM possible:wink:

I tried to find out if my P4 with my SSD on USB3 supports Trim.
I’ve accessed my HA using ‘SSH Server’, not to be mistaken by ‘Terminal & SSH’, which doesn’t give core access.

Had to additional install the packages util-linux, lsscsi and sg3_utils to be able to enter all the required commands the above instructions show. Dispite all effort, sg_vpd -p bl /dev/sda andsg_vpd -p lbpv /dev/sda result in a sg_vpd failed: Operation not permitted error.

Sync it seems a big risk just to enable trim/discard, I wonder anyone has other tricks up their sleeve.

I would not risk it, if you arent sure if your SSD and controller supports TRIM, dont do it directly on RPI4. They guys who did the guide already wrote a warning on it.

Test in a laptop or PC and run live linux CD.

I was going to buy RPI4 but for a few extra $ $200 CAD to be exact I was able to pickup a Dell 3060 which is way more powerfull and now in the process of migrating running Proxmox and container method. On top I am now running PiHole on same box.

Yeah, I’ve read the warnings, that’s why I’ve put in the effort to figure out if my hardware supports it. Big change it does, but I’m not willing to push my luck. Having HA crash isn’t my idea of fun. I was just hoping someone had an idea to work around the Operation not permitted-error without shutting down and disconnecting the disk from HA.