29 | | The detailed selection logic used by the kernel to decide which devices get this flag can be found in the `uas_use_uas_driver()` function in the [https://github.com/torvalds/linux/blob/master/drivers/usb/storage/uas-detect.h drivers/usb/storage/uas-detect.h] combined with the list of entries found in the [https://github.com/torvalds/linux/blob/master/drivers/usb/storage/unusual_uas.h drivers/usb/storage/unusual_uas.h] |
| 22 | You can easily check to see whether the kernel using uas or usbstorage for a particular device using the `lsusb -t` command: |
| 23 | |
| 24 | {{{ |
| 25 | # lsusb -t |
| 26 | /: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 10000M |
| 27 | /: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M |
| 28 | /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M |
| 29 | |__ Port 1: Dev 11, If 0, Class=Mass Storage, Driver=usb-storage, 5000M |
| 30 | [...] |
| 31 | }}} |
| 32 | or |
| 33 | {{{ |
| 34 | # lsusb -t |
| 35 | /: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 10000M |
| 36 | /: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M |
| 37 | /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M |
| 38 | |__ Port 1: Dev 8, If 0, Class=Mass Storage, Driver=uas, 5000M |
| 39 | [...] |
| 40 | }}} |
| 41 | |
| 42 | Alternatively you can check the messages that appear in kern.log when the device is first connected and look for the driver name mentioned at the end of the "scsi hostN" line: |
| 43 | {{{ |
| 44 | usb 2-1: new SuperSpeed USB device number 8 using xhci_hcd |
| 45 | usb 2-1: New USB device found, idVendor=NNNN, idProduct=NNN |
| 46 | usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 |
| 47 | [...] |
| 48 | scsi host4: uas |
| 49 | scsi 4:0:0:0: Direct-Access VENDOR-NAME 0204 PQ: 0 ANSI: 6 |
| 50 | sd 4:0:0:0: Attached scsi generic sg2 type 0 |
| 51 | sd 4:0:0:0: [sdc] 1953525168 512-byte logical blocks: (1.00 TB/932 GiB) |
| 52 | sd 4:0:0:0: [sdc] 4096-byte physical blocks |
| 53 | sd 4:0:0:0: [sdc] Write Protect is off |
| 54 | sd 4:0:0:0: [sdc] Mode Sense: 53 00 00 08 |
| 55 | sd 4:0:0:0: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA |
| 56 | sdc: sdc1 sdc2 |
| 57 | sd 4:0:0:0: [sdc] Attached SCSI disk |
| 58 | }}} |
| 59 | |
| 60 | or |
| 61 | |
| 62 | {{{ |
| 63 | usb 2-1: new SuperSpeed USB device number 9 using xhci_hcd |
| 64 | usb 2-1: New USB device found, idVendor=NNNN, idProduct=NNNN |
| 65 | usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 |
| 66 | [...] |
| 67 | usb-storage 2-1:1.0: USB Mass Storage device detected |
| 68 | scsi host4: usb-storage 2-1:1.0 |
| 69 | scsi 4:0:0:0: Direct-Access VENDOR-NAME 0204 PQ: 0 ANSI: 6 |
| 70 | sd 4:0:0:0: Attached scsi generic sg2 type 0 |
| 71 | 1953525168 512-byte logical blocks: (1.00 TB/932 GiB) |
| 72 | sd 4:0:0:0: [sdc] Write Protect is off |
| 73 | sd 4:0:0:0: [sdc] Mode Sense: 47 00 00 08 |
| 74 | sd 4:0:0:0: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA |
| 75 | sdc: sdc1 sdc2 |
| 76 | sd 4:0:0:0: [sdc] Attached |
| 77 | }}} |
| 78 | |
| 79 | The detailed selection logic used by the kernel to decide which devices get this flag can be found in the `uas_use_uas_driver()` function in the [https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/storage/uas-detect.h drivers/usb/storage/uas-detect.h] combined with the list of entries found in the [https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/storage/unusual_uas.h drivers/usb/storage/unusual_uas.h] |
92 | | == Permanent Workarounds == |
93 | | |
94 | | |
95 | | |
96 | | == Short-term Workarounds == |
97 | | |
| 142 | == Workarounds == |
| 143 | |
| 144 | There are two approaches to getting smartmontools to work with one of these devices, both involving setting a "quirks" flag for the device in question. |
| 145 | |
| 146 | * If you just want to get smartmontools working again and don't care about the performance improvements the come from using UAS mode, you can simply use the IGNORE_UAS flag to tell Linux to stick with the usb-storage mode instead, by using the "u" flag on the `usb-storage.quirks` setting. |
| 147 | |
| 148 | * If you want to continue using UAS mode and are sure your particular device does properly support SAT mode even though the kernel detects it as a device that does not (e.g. as described in ticket:971#comment:12) , you can override that default configuration by passing an empty flag list in the `usb-storage.quirks` setting. |
| 149 | |
| 150 | Note that in either case, you will need to find the idVendor and idProduct fields for your device, in 4-digit hex format. This information is found in the `New USB device found, idVendor=NNNN, idProduct=NNNN` |
| 151 | kern.log line, or in the output from "lsusb". (In the option strings below, the 4-digit numbers can optionally be preceded a "0x" prefix.) |
| 152 | |
| 153 | == Permanent Flag Settings == |
| 154 | |
| 155 | The `usb-storage.quirks` option is part of the more general mechanism for setting kernel/module options, and the exact mechanisms available for setting it will vary depending on your distribution. In brief: |
| 156 | |
| 157 | * if your system has the "usb-storage" driver compiled as a loadable kernel module, you can set it by creating a file (e.g. `disable_uas.conf`) under `/etc/modprobe.d/` containing the line (with the proper id numbers substituted) |
| 158 | {{{ |
| 159 | options usb-storage quirks=0bc2:231a:u |
| 160 | }}} |
| 161 | to disable UAS for that device (or |
| 162 | {{{ |
| 163 | options usb-storage quirks=0bc2:231a: |
| 164 | }}} |
| 165 | to try overriding the default NO_ATA_1X flag). |
| 166 | |
| 167 | You will then probably need to follow your distribution's instructions for rebuilding your initramdisk in order to make the change apply when usb-storage drives are detected upon initial bootup. |
| 168 | |
| 169 | * If the "usb-storage" driver is built in to the kernel, or if you simply prefer to make this change at the boot level rather than under /etc/modproble.d/, you can pass the option to the kernel as part of your boot configuration. For example, if your system uses grub2, you can edit `/boot/grub/default` so that in includes a line similar to |
| 170 | {{{ |
| 171 | GRUB_CMDLINE_LINUX="usb_storage.quirks=0bc2:231a:u" |
| 172 | }}} |
| 173 | and then run `update-grub`, and then reboot. |
| 174 | |
| 175 | (Note that while the basic information used in these two approaches in the same, the punctuation used is different.) |
| 176 | |
| 177 | In either case, you can then try plugging your USB device in again, and confirm using one of the methods above that the change had taken effect. (Note that if you use the `:u` flag, the kern.log messages generated when the device is detected should now include |
| 178 | {{{ |
| 179 | usb 2-1: UAS is blacklisted for this device, using usb-storage instead |
| 180 | usb-storage 2-1:1.0: USB Mass Storage device detected |
| 181 | usb-storage 2-1:1.0: Quirks match for vid 0bc2 pid ab38: 800000 |
| 182 | scsi host4: usb-storage 2-1:1.0 |
| 183 | }}} |
| 184 | |
| 185 | |
| 186 | == Temporary Settings == |
| 187 | |
| 188 | If you would like to temporarily set the quirks flag rather than making a permanent change (e.g. in order to run smartctl manually at some point but continuing to use UAS mode normally when using the drive for data transfers), you can do so by dynamically updating the module configuration. |
| 189 | |
| 190 | First, unmount/unplug the USB device, then run the following commands (as root): |
| 191 | |
| 192 | {{{ |
| 193 | # cat /sys/module/usb_storage/parameters/quirks |
| 194 | |
| 195 | # echo "0x0bc2:0x231a:u" > /sys/module/usb_storage/parameters/quirks |
| 196 | # cat /sys/module/usb_storage/parameters/quirks |
| 197 | 0x0bc2:0x231a:u |
| 198 | |
| 199 | }}} |
| 200 | |
| 201 | (Note that the "echo" command completely replaces the current setting, so the first "cat" command makes sure that no quirks have been previously configured; it should just show a blank line.) |
| 202 | |
| 203 | At this point you can plug the device's USB cable back in, and (after confirming via lsusb/kern.log that the device is connected to the usb-storage driver) you can then proceed to access the device using SAT. |
| 204 | |
| 205 | A quirk set in this manner will automatically get cleared the next time the system is rebooted, but if you want to clear it more quickly you can simply execute: |
| 206 | {{{ |
| 207 | # echo "" > /sys/module/usb_storage/parameters/quirks |
| 208 | }}} |
| 209 | to clear the configuration for the next time the device is plugged in. |
| 210 | |
| 211 | == Useful Links == |
| 212 | |
| 213 | A few pages with useful additional information: |
| 214 | |
| 215 | General info: |
| 216 | * [https://superuser.com/questions/928741/how-can-i-check-whether-usb3-0-uasp-usb-attached-scsi-protocol-mode-is-enabled StackExchange: How can I check whether USB3.0 UASP (USB Attached SCSI Protocol) mode is enabled in Linux?] |
| 217 | * [https://en.opensuse.org/SDB:USB_3.0_Hard_Drive_troubleshooting Suze:USB 3.0 Hard Drive troubleshooting] |
| 218 | |
| 219 | Examples of the problems that originally triggered the current kernel behavior: |
| 220 | * [https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1584557 Seagate external drive causes SCSI bus resets when UAS enabled] |
| 221 | * [https://unix.stackexchange.com/questions/441668/debian-usb3-hdd-uas-i-o-errors StackExchange: Debian + USB3 HDD + UAS: I/O errors] |
| 222 | * [https://unix.stackexchange.com/questions/418326/how-do-i-make-my-seagate-2tb-usb-hdd-work-in-linux StackExchange: How do I make my Seagate 2Tb usb hdd work in Linux?] |
| 223 | |