Discard over USB

What It Does
Trim and discard are two different names for the same thing.

The mount option is called discard, the fstrim command does the same thing but not as it happens. Both inform the underlying block device about space that the filesystem was using but has been returned to the free pool. In general this is a good thing as FLASH based devices can only change memory cells in one direction. They must be erased before they can be rewritten. Erase is a slow operation, much slower than write, so discard gives the block device the information it needs to erase the discarded blocks in good time before they need to be rewritten. This in turn maintains the write performance of the device.

Why is USB Special
With NVME or SATA connected FLASH devices, trim/discard just works. When a USB adaptor is involved trim is usually disabled by default and need to be enable before it can be used.

Readers who have moved a FLASH based block device to a USB enclosure may have noticed a dmesg warning Discard is not supported.

Prerequsites
A USB3 link to the FLASH device. USB2 cannot support trim. A USB3 to FLASH bridge that actually supports trim sys-apps/sg3_utils sys-apps/usbutils

Note: Some USB3 to FLASH bridges can have their firmware upgraded to support trim.

Testing That Trim is Supported
to get the required tools.