Enable TRIM/Discard on USB for Linux

Last Modified: Tue, 23 Apr 2024 14:21:03 +0000 ; Created: Fri, 02 Feb 2024 19:27:21 +0000

Enable TRIM/discard on external SSD - 2024-02-02

In case the link goes 404

lsblk --discard
# DISC-GRAN and DISC-MAX not zero means already good to go

sg_vpd -a /dev/sdX | grep -i unmap

cat /sys/block/sdb/device/scsi_disk/6\:0\:0\:0/provisioning_mode
# want unmap, not full as response

# vim on /etc/udev/rules.d/90-usb-discard.rules
ACTION=="add|change", ATTRS{idVendor}=="0b05", ATTRS{idProduct}=="1932", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"

# get your values for idVendor and idProduct from the command

# Reboot to make sure it sticks after a reboot