Disabling uas driver on a USB SSD?

I have been experiencing system hangs due to my boot drive / apps drive being on a USB SSD. (Yes - I know this is unsupported.)

USB 3 drives have a greater propensity for disconnects or similar, as do drives that utilise the uas driver.

I am trying to understand whether it is possible to disable the uas driver and get TrueNAS SCALE to load the usb storage driver instead.

Since lsusb utility is not installed with SCALE, here is the relevant part of cat /sys/kernel/debug/usb/devices:

T:  Bus=01 Lev=01 Prnt=01 Port=03 Cnt=02 Dev#=  3 Spd=480  MxCh= 0
D:  Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=2109 ProdID=0715 Rev= 2.63
S:  Manufacturer=SSK Corporation
S:  Product=SSK USB3.2 SSD Flash Drive
S:  SerialNumber=ABCDEFA75521
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=uas
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#= 0 Alt= 1 #EPs= 4 Cls=08(stor.) Sub=06 Prot=62 Driver=uas
E:  Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=06(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=87(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms

Anyone got any ideas?

I vaguely recall a file that can be edited to blacklist kernel modules. But, I don’t remember the name. Further, on TrueNAS SCALE it may not survive a reboot, which may be necessary to force un-load the un-wanted module.

A quick search found this;
https://wiki.debian.org/KernelModuleBlacklisting

Here is where I am at right now.

I think that what is happening when I get a USB glitch is that it manifests as an I/O error on one of the two pools on the USB SSD, and because the zfs pool property failmode is set to wait, the pool hangs until you issue a clear on it, but you cannot do this because you can’t get access to the UI to do it.

I have now set failmode to continue for both of the pools, which places the pool in read-only status until you can run a clear against it - and I will see if this helps.

sudo zpool set failmode=continue boot-pool

As an aside I also noted that the boot-pool has autotrim=off as standard - and there is no UI available to turn it on.

I have therefore also done sudo zpool set autotrim=on boot-pool because I cannot see how this could hurt, but if anyone thinks otherwise, please let me know.

Of course this is quite old, but:

I had the same need as I have an NVME drive connected via a USB-C enclosure as I’m otherwise totally out of slots on the board, and any PCIe slots that could fit more converter cards. It’s just a scratch drive where data loss is a non issue.

This drive once every 1-2 months will be marked as suspended due to a sudden burst of I/O failures with no clear reason or pattern as to why (i.e. it doesn’t always occur right after some kind of scheduled maintenance task or similar).

The only thing I was able to suss out as even a possibility is that as great as uas is, implementations of it can be finicky or otherwise poor, and that it’s worth seeing if forcing the kernel to use the usb-storage driver for the device makes the problem stop, if your use case can tolerate the slight-to-moderate performance loss from the older driver.

If anyone else wants to try this, what you should do it execute the following (after inserting the correct values, then reboot (WARNING THIS WILL REPLACE EXISTING KERNEL EXTRA OPTIONS IF ANY YOU HAVE ANY ALREADY. SEE THE LATER SCRIPT FOR A BETTER SOLUTION IF SO):


midclt call system.advanced.update '{"kernel_extra_options": "usb-storage.quirks=xxxx:yyyy:u"}'

Where the values are as follows:

xxxx: USB Vendor ID
yyyy: Product ID

For example, 0bda:9210 is the full value for my Realtek RTL9210 based enclosure.

These values can be found in kernel logs, particularly from around when the device is connected. Note however that this command targets the controller of the enclosure by model so it will apply to any other USB enclosures you may also use and cannot be used to only affect one device. Generally this is fine, because if that controller does have a cruddy uas driver that should be avoided, then chances are you’d want that for all of your USB connected drives that use that controller.

The change should survive reboots and upgrades, but to be totally safe you could write a basic script that runs as post-init that first probes the kernel to see if the quirk is present and then adds it if it’s missing:

#!/bin/bash
QUIRK="usb-storage.quirks=0bda:9210:u"

CURRENT=$(midclt call system.advanced.config | jq -r '.kernel_extra_options // ""')

if \[\[ "$CURRENT" != *"$QUIRK"* \]\]; then
    NEW=$(echo "$CURRENT $QUIRK" | xargs)
    midclt call system.advanced.update "$(jq -n --arg v "$NEW" '{kernel_extra_options: $v}')"
    logger -t ensure-uas-quirk "Kernel option was missing; re-added. Reboot needed to apply."
fi

As noted it won’t take effect till a reboot occurs, but ensures the fix will be applied again relatively quickly if it ever gets removed. You could add a forced reboot to the script (if having the system possibly suddenly reboot after, say, an update, is acceptable.

If going this method, just run this script manually once to enable the quirk for the first time.

Great work.

This simply means that Windows deals with USB drives much better than Linux.

(The same exact drives never disconnected or had any issues under windows. In fact, I have enough windows with usb drives that have never had any issues after years of use.

Same for FreeBSD, don’t remember ever having USB drive issues).

@truenas-fan - You may be right.

However, many MS-Windows desktops don’t seem to hit their USB connected storage hard.

One recent example for me, was a brand new 3.5" external USB 3 enclosure WITH FAN, where the drive practically melted into a puddle. To be fair, I was running 24 hours of BadBlocks before I put the new drive into my NAS.

But, if MS-Windows experienced this, and had drive failures, that specific enclosure would be blacklisted faster than the Internet could talk about it.


Back to original thread, ZFS write transaction groups can be quite large and very bursty. This may be different write behavior than MS-Windows. I would guess that many / most vendor testing for USB attached storage devices is done on MS-Windows. Then some done on MAC OS. With the least amount done on Linux.

It is likely only users and open source developers test USB external storage enclosures with ZFS. Thus, the vendors target what seems to make the most money, MS-Windows, (and some to MAC OS).