TRIM support for USB drives?

olli@

Developer
I've got two external SSD drives (Samsung T5) that support TRIM / UNMAP according to the vendor's specifications. However, FreeBSD doesn't seem to recognize that feature: diskinfo -v says it's not supported, and when I run newfs -t on the drive and then mount it, I also get a message saying that TRIM is not supported. This is stable/12 (amd64), just a few days old. Other than that, the drives work ok with FreeBSD, although much slower than under Windows or Linux, but I think that's a known issue of FreeBSD's USB stack. smartctl on the drives also works fine.

Does anyone know if TRIM / UNMAP is generally unsupported for USB drives with FreeBSD? I remember seeing commits some time ago that referred to USB + TRIM, but I don't remember the details. Does it only work for certain kinds of USB devices?
 
Last edited:
Are you sure they support it? I remember the T3 and it didn't support it.
Try using tunefs -t enable /dev/xxx
(oh, where xxx is your usb device)
 
Are you sure they support it? I remember the T3 and it didn't support it.
Yes, that's a new feature of the T5. See the Review at Tom's Hardware (“Previous versions of the Samsung Portable SSD did not support TRIM. The new T5 products accept the command from the host through the UASP protocol.”) and the Review at AnandTech (“Support for TRIM (unavailable in the previous Samsung Portable SSDs)”).
Try using tunefs -t enable /dev/xxx
(oh, where xxx is your usb device)
That has exactly the same effect as newfs -t.

Reading the review at Tom's Hardware (see the link above), it says that support for TRIM is only available through the UASP protocol. As far as I know, FreeBSD does not support UASP … That also explains why the SSD is rather slow with FreeBSD, I guess. :-(
 
Update …

It turned out that the cause of the problem is that FreeBSD does not support UAS / UASP. That's a newer USB protocol for accessing storage devices. Well, “newer” means it was introduced as part of USB 3.0 in 2010. It's supported by all major OS like Windows, Linux, MacOS, and even uncommon ones like Solaris. That's also the reason why the Samsung T5 SSDs are five times faster (!) in Windows and Linux. Also, NCQ and TRIM support works fine with Windows and Linux, but does not work with FreeBSD because it requires UAS / UASP. :(

The maximum throughput (reading data) I can get under FreeBSD is 110 MB/s. With Windows and Linux it's about 500 MB/s (+/-), depending on the kind of access pattern. Both of that is with a USB 3.x Gen 2 port, of course. Quite a huge difference, especially when transferring large video files, which I do a lot. Makes me wonder if it's worth booting Linux, saving one hour for transferring 500 GB (15 minutes instead of 1 hour and 15 minutes).
 
For searching fun, the "bulk stream" or "bulk endpoint streams" in USB 3.0 seems to have some kind of support in FreeBSD's stack, but is used by no drivers.
Yes, I found those posts, too, among others. Unfortunately it doesn't help because FreeBSD still only supports the old USB 2.0 “BOT” mode (bulk-only transfer) for storage devices, but not the newer UAS / UASP. This is becoming more and more of a problem, since such devices become more common.

I also think this is not a problem of the XHCI controllers – The UAS protocol is nearly 10 years old, and nowadays basically all USB controllers support it. My T5 SSDs work fine at their full speed on every non-FreeBSD machine I've tried so far, provided that it has USB 3.x Gen 2 ports.
 
I have a bunch of those T5 drives I use for backups. They're an outstanding product. Hoping FreeBSD will come to support the UAS protocol sooner than later.
 
Back
Top