spod.cx

Enabling TRIM Support on a Via VL817 USB 3.1 SATA Adaptor

Mainly here as a reminder for myself, but hopefully others may find this useful.

The Via VL817 USB 3.1 SATA adaptor supports UASP mode, and can be convinced to enable TRIM support in Linux. This means you can also run blkdiscard to erase the drive, which was my primary use case.

This probably works with other adaptors too, but this one is a "Sabrent USB 3.1 (Type-A) to SSD / 2.5-Inch SATA Hard Drive Adapter [Optimized For SSD, Support UASP SATA III] (EC-SS31)" I bought from Amazon. You can find it here

First, check your device is showing up with 'Driver=uas':

# lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 5000M
    |__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=uas, 5000M

Then verify that unmap is supported - you're looking for "Unmap command supported (LBPU): 1". On debian buster I needed to apt install sg3-utils for sg_vpd.

# sg_vpd -a /dev/sda
Logical block provisioning VPD page (SBC):
  Unmap command supported (LBPU): 1
  Write same (16) with unmap bit supported (LBPWS): 0
  Write same (10) with unmap bit supported (LBPWS10): 0

Confirm the device ID for your adaptor using lsusb:

# lsusb
Bus 002 Device 002: ID 2109:0715 VIA Labs, Inc. 

The bus and device should match those from the 'lsusb -t' command you ran earlier.

Create /etc/udev/rules.d/50-uasp-usb.rules with the following content:

ACTION=="add|change", ATTRS{idVendor}=="2109", ATTRS{idProduct}=="0715", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"

Amend the vendor and product IDs if you need to.

Then reload udev:

# udevadm control --reload-rules && udevadm trigger

You should now find that TRIM works on that device. In my case, I wanted to quickly erase an SSD using the blkdiscard command which now works without returning an error and does indeed zero out the entire SSD. DO NOT RUN THIS UNLESS YOU WISH TO LOSE ALL YOUR DATA...

# blkdiscard /dev/sda
# 

The version of smartctl on Debian Buster doesn't seem to know about this device yet, so if you get the following error running smartctl:

/dev/sda: Unknown USB bridge [0x2109:0x0715 (0xa000)]
Please specify device type with the -d option.

You can fix this by passing in the '-d sat' argument:

# smartctl -d sat -a /dev/sda

Contact: site@spod.cx