I have an SSD (Samsung 860 EVO) attached via an USB-SATA adapter (I tried both this one and this one) to an ARM computer (Odroid N2) running Armbian (Linux 4.9.180).
I partitionned it with LVM (simple setup: a single PV, VG, and LV; no encryption). But when I mount it, I get this warning in dmesg:
[87990.092895] EXT4-fs (dm-0): mounting with "discard" option, but the device does not support discard
and fstrim fails:
# fstrim /var/lib/postgresql
fstrim: /var/lib/postgresql: the discard operation is not supported
I checked, and hdpart indicates that the hardware should support TRIM:
# hdparm -I /dev/sda | grep TRIM
* Data Set Management TRIM supported (limit 8 blocks)
* Deterministic read ZEROs after TRIM
lsusb and dmesg confirm this is an UAS/SCSI device:
# lsusb -t
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 5000M
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 5000M
|__ Port 3: Dev 5, If 0, Class=Mass Storage, Driver=uas, 5000M
# dmesg
[...]
[87893.325796] scsi host0: uas
[87893.337014] scsi 0:0:0:0: Direct-Access Samsung SSD 860 EVO 500G 3202 PQ: 0 ANSI: 6
[87893.394341] sd 0:0:0:0: Attached scsi generic sg0 type 0
[87893.394928] sd 0:0:0:0: [sda] 976773168 512-byte logical blocks: (500 GB/466 GiB)
[87893.394938] sd 0:0:0:0: [sda] 4096-byte physical blocks
[87893.395718] sd 0:0:0:0: [sda] Write Protect is off
[87893.395729] sd 0:0:0:0: [sda] Mode Sense: 53 00 00 08
[87893.396153] sd 0:0:0:0: [sda] Disabling FUA
[87893.396163] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[87893.396322] xhci-hcd xhci-hcd.0.auto: ERROR Transfer event for disabled endpoint or incorrect stream ring
[87893.396331] xhci-hcd xhci-hcd.0.auto: @00000000cf6128b0 00000000 00000000 1b000000 03078001
[87893.396593] sd 0:0:0:0: [sda] Optimal transfer size 33553920 bytes not a multiple of physical block size (4096 bytes)
[87893.401435] sda: sda1
[87893.404218] sd 0:0:0:0: [sda] Attached SCSI disk
[87990.092895] EXT4-fs (dm-0): mounting with "discard" option, but the device does not support discard
[87990.092901] EXT4-fs (dm-0): mounted filesystem with ordered data mode. Opts: discard
But lsblk indicates the device does not support DISCARD/TRIM ("in DISC-GRAN and DISC-MAX [...] non-zero values indicate TRIM support"):
# lsblk --discard
NAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda 0 0B 0B 0
`-sda1 0 0B 0B 0
`-vg0-pg_data0 0 0B 0B 0
Edit: I tried connecting the disk+adapter to a different computer; results are the same (except there are no errors in dmesg)
What should I do to enable support for TRIM/DISCARD/fstrim?