Kernel

Linux 上 USB3 外部儲存的連接問題(UAS 驅動程序問題)

  • June 20, 2020

在 Ubuntu 15.10 上,當我想使用 NTFS 文件系統格式化通過 USB3 連接的外部 4TO 磁碟(在 StarTech USB/eSATA 硬碟底座上)時,我有很多I/O 錯誤,並且格式化失敗。

我嘗試了 GParted v 0.19,並在最新的 live CD 上嘗試了 GParted,但也遇到gparted-live-0.23.0-1-i586.iso了同樣的問題。

之後,在 Ubuntu 15.10 上使用 GParted 和相同的 USB3 連接,我嘗試格式化為ext4,沒有問題。這真的很奇怪。

因為不知道mkfs.ext4GParted用來格式化磁碟的工具測試磁碟是否喜歡(或不喜歡)mkntfs,所以我首先假設問題與新磁碟有關。也許這個新磁碟引起了問題。所以我嘗試e2fsck -c在這個硬碟上執行。在 Ubuntu 15.10 上,e2fsck -c凍結在 0.45%,我不知道為什麼。

因此,在同一台 PC 上使用另一個版本的 Ubuntu (15.04),我嘗試使用 StarTech HDD 擴展塢的 eSATA 連接來連接同一個 4TO 磁碟。這一次,e2fsck -c執行正常。

幾個小時後,您可以看到結果:

sudo e2fsck -c /dev/sdc1
e2fsck 1.42.12 (29-Aug-2014)
ColdCase : récupération du journal
Vérification des blocs défectueux (test en mode lecture seule) : complété                                             
ColdCase: Updating bad block inode.
Passe 1 : vérification des i-noeuds, des blocs et des tailles
Passe 2 : vérification de la structure des répertoires
Passe 3 : vérification de la connectivité des répertoires
Passe 4 : vérification des compteurs de référence
Passe 5 : vérification de l'information du sommaire de groupe

ColdCase: ***** LE SYSTÈME DE FICHIERS A ÉTÉ MODIFIÉ *****
ColdCase : 11/244195328 fichiers (0.0% non contigus), 15377150/976754176 blocs

我不是badblock輸出專家,但這個磁碟上似乎根本沒有壞塊?

那麼,如果問題不是硬碟驅動器,也許問題可以連結到mkntfs使用USB3?我還可以嘗試哪些其他測試?

有關 USB 塢站的一些資訊:

➜  ~  lsusb
...
Bus 002 Device 002: ID 174c:55aa ASMedia Technology Inc. ASM1051E SATA 6Gb/s bridge, ASM1053E SATA 6Gb/s bridge, ASM1153 SATA 3Gb/s bridge
...


➜  ~  sudo lsusb -v -d 174c:55aa
Mot de passe [sudo] pour reyman : 

Bus 002 Device 002: ID 174c:55aa ASMedia Technology Inc. ASM1051E SATA 6Gb/s bridge, ASM1053E SATA 6Gb/s bridge, ASM1153 SATA 3Gb/s bridge
Device Descriptor:
 bLength                18
 bDescriptorType         1
 bcdUSB               3.00
 bDeviceClass            0 (Defined at Interface level)
 bDeviceSubClass         0 
 bDeviceProtocol         0 
 bMaxPacketSize0         9
 idVendor           0x174c ASMedia Technology Inc.
 idProduct          0x55aa ASM1051E SATA 6Gb/s bridge, ASM1053E SATA 6Gb/s bridge, ASM1153 SATA 3Gb/s bridge
 bcdDevice            1.00
 iManufacturer           2 asmedia
 iProduct                3 ASM1053E
 iSerial                 1 123456789012
 bNumConfigurations      1
 Configuration Descriptor:
   bLength                 9
   bDescriptorType         2
   wTotalLength          121
   bNumInterfaces          1
   bConfigurationValue     1
   iConfiguration          0 
   bmAttributes         0xc0
     Self Powered
   MaxPower               36mA
   Interface Descriptor:
     bLength                 9
     bDescriptorType         4
     bInterfaceNumber        0
     bAlternateSetting       0
     bNumEndpoints           2
     bInterfaceClass         8 Mass Storage
     bInterfaceSubClass      6 SCSI
     bInterfaceProtocol     80 Bulk-Only
     iInterface              0 
     Endpoint Descriptor:
       bLength                 7
       bDescriptorType         5
       bEndpointAddress     0x81  EP 1 IN
       bmAttributes            2
         Transfer Type            Bulk
         Synch Type               None
         Usage Type               Data
       wMaxPacketSize     0x0400  1x 1024 bytes
       bInterval               0
       bMaxBurst              15
     Endpoint Descriptor:
       bLength                 7
       bDescriptorType         5
       bEndpointAddress     0x02  EP 2 OUT
       bmAttributes            2
         Transfer Type            Bulk
         Synch Type               None
         Usage Type               Data
       wMaxPacketSize     0x0400  1x 1024 bytes
       bInterval               0
       bMaxBurst              15
   Interface Descriptor:
     bLength                 9
     bDescriptorType         4
     bInterfaceNumber        0
     bAlternateSetting       1
     bNumEndpoints           4
     bInterfaceClass         8 Mass Storage
     bInterfaceSubClass      6 SCSI
     bInterfaceProtocol     98 
     iInterface              0 
     Endpoint Descriptor:
       bLength                 7
       bDescriptorType         5
       bEndpointAddress     0x81  EP 1 IN
       bmAttributes            2
         Transfer Type            Bulk
         Synch Type               None
         Usage Type               Data
       wMaxPacketSize     0x0400  1x 1024 bytes
       bInterval               0
       bMaxBurst              15
       MaxStreams             16
       Data-in pipe (0x03)
     Endpoint Descriptor:
       bLength                 7
       bDescriptorType         5
       bEndpointAddress     0x02  EP 2 OUT
       bmAttributes            2
         Transfer Type            Bulk
         Synch Type               None
         Usage Type               Data
       wMaxPacketSize     0x0400  1x 1024 bytes
       bInterval               0
       bMaxBurst              15
       MaxStreams             16
       Data-out pipe (0x04)
     Endpoint Descriptor:
       bLength                 7
       bDescriptorType         5
       bEndpointAddress     0x83  EP 3 IN
       bmAttributes            2
         Transfer Type            Bulk
         Synch Type               None
         Usage Type               Data
       wMaxPacketSize     0x0400  1x 1024 bytes
       bInterval               0
       bMaxBurst              15
       MaxStreams             16
       Status pipe (0x02)
     Endpoint Descriptor:
       bLength                 7
       bDescriptorType         5
       bEndpointAddress     0x04  EP 4 OUT
       bmAttributes            2
         Transfer Type            Bulk
         Synch Type               None
         Usage Type               Data
       wMaxPacketSize     0x0400  1x 1024 bytes
       bInterval               0
       bMaxBurst               0
       Command pipe (0x01)
Binary Object Store Descriptor:
 bLength                 5
 bDescriptorType        15
 wTotalLength           22
 bNumDeviceCaps          2
 USB 2.0 Extension Device Capability:
   bLength                 7
   bDescriptorType        16
   bDevCapabilityType      2
   bmAttributes   0x00000002
     Link Power Management (LPM) Supported
 SuperSpeed USB Device Capability:
   bLength                10
   bDescriptorType        16
   bDevCapabilityType      3
   bmAttributes         0x00
   wSpeedsSupported   0x000e
     Device can operate at Full Speed (12Mbps)
     Device can operate at High Speed (480Mbps)
     Device can operate at SuperSpeed (5Gbps)
   bFunctionalitySupport   1
     Lowest fully-functional device speed is Full Speed (12Mbps)
   bU1DevExitLat          10 micro seconds
   bU2DevExitLat        2047 micro seconds
Device Status:     0x0001
 Self Powered

有關問題磁碟的資訊:/dev/sdd

➜  ~  sudo fdisk -l /dev/sdd
Disque /dev/sdd : 3,7 TiB, 4000787030016 octets, 7814037168 secteurs
Unités : sectors of 1 * 512 = 512 octets
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 33553920 bytes
Disklabel type: gpt
Disk identifier: ACD5760B-2898-435E-82C6-CB3119758C9B

Périphérique Start        Fin   Secteurs  Size Type
/dev/sdd1     2048 7814035455 7814033408  3,7T Linux filesystem

dmesg返回很多關於磁碟的錯誤;看到這個摘錄:

[   68.856381] scsi host6: uas_eh_bus_reset_handler start
[   68.968376] usb 2-2: reset SuperSpeed USB device number 2 using xhci_hcd
[   68.989825] scsi host6: uas_eh_bus_reset_handler success
[   99.881608] sd 6:0:0:0: [sdd] tag#12 uas_eh_abort_handler 0 uas-tag 13 inflight: CMD OUT 
[   99.881618] sd 6:0:0:0: [sdd] tag#12 CDB: Write(16) 8a 00 00 00 00 00 e8 c4 08 00 00 00 00 08 00 00
[   99.881856] sd 6:0:0:0: [sdd] tag#5 uas_eh_abort_handler 0 uas-tag 6 inflight: CMD OUT 
[   99.881861] sd 6:0:0:0: [sdd] tag#5 CDB: Write(16) 8a 00 00 00 00 00 cd 01 08 f0 00 00 00 10 00 00
[   99.881967] sd 6:0:0:0: [sdd] tag#4 uas_eh_abort_handler 0 uas-tag 5 inflight: CMD OUT 
[   99.881972] sd 6:0:0:0: [sdd] tag#4 CDB: Write(16) 8a 00 00 00 00 00 cd 01 08 00 00 00 00 f0 00 00
[   99.882085] sd 6:0:0:0: [sdd] tag#3 uas_eh_abort_handler 0 uas-tag 4 inflight: CMD OUT 
[   99.882090] sd 6:0:0:0: [sdd] tag#3 CDB: Write(16) 8a 00 00 00 00 00 cd 01 07 10 00 00 00 f0 00 00
[   99.882171] sd 6:0:0:0: [sdd] tag#2 uas_eh_abort_handler 0 uas-tag 3 inflight: CMD OUT 
[   99.882175] sd 6:0:0:0: [sdd] tag#2 CDB: Write(16) 8a 00 00 00 00 00 cd 01 06 20 00 00 00 f0 00 00
[   99.882255] sd 6:0:0:0: [sdd] tag#1 uas_eh_abort_handler 0 uas-tag 2 inflight: CMD OUT 
[   99.882258] sd 6:0:0:0: [sdd] tag#1 CDB: Write(16) 8a 00 00 00 00 00 cd 01 05 30 00 00 00 f0 00 00
[   99.882338] sd 6:0:0:0: [sdd] tag#0 uas_eh_abort_handler 0 uas-tag 1 inflight: CMD OUT 
[   99.882342] sd 6:0:0:0: [sdd] tag#0 CDB: Write(16) 8a 00 00 00 00 00 cd 01 04 40 00 00 00 f0 00 00
[   99.882419] sd 6:0:0:0: [sdd] tag#11 uas_eh_abort_handler 0 uas-tag 12 inflight: CMD OUT 
[   99.882423] sd 6:0:0:0: [sdd] tag#11 CDB: Write(16) 8a 00 00 00 00 00 cd 00 f9 00 00 00 00 f0 00 00
[   99.882480] sd 6:0:0:0: [sdd] tag#10 uas_eh_abort_handler 0 uas-tag 11 inflight: CMD OUT 
[   99.882483] sd 6:0:0:0: [sdd] tag#10 CDB: Write(16) 8a 00 00 00 00 00 cd 00 f9 f0 00 00 00 f0 00 00
[   99.882530] sd 6:0:0:0: [sdd] tag#9 uas_eh_abort_handler 0 uas-tag 10 inflight: CMD OUT 
[   99.882532] sd 6:0:0:0: [sdd] tag#9 CDB: Write(16) 8a 00 00 00 00 00 cd 00 fa e0 00 00 00 f0 00 00
[   99.882593] sd 6:0:0:0: [sdd] tag#8 uas_eh_abort_handler 0 uas-tag 9 inflight: CMD 
[   99.882596] sd 6:0:0:0: [sdd] tag#8 CDB: Write(16) 8a 00 00 00 00 00 cd 00 fb d0 00 00 00 f0 00 00
[   99.882667] scsi host6: uas_eh_bus_reset_handler start
[   99.994700] usb 2-2: reset SuperSpeed USB device number 2 using xhci_hcd
[  100.015613] scsi host6: uas_eh_bus_reset_handler success
[  135.962175] sd 6:0:0:0: [sdd] tag#5 uas_eh_abort_handler 0 uas-tag 6 inflight: CMD OUT 
[  135.962185] sd 6:0:0:0: [sdd] tag#5 CDB: Write(16) 8a 00 00 00 00 00 cd 40 78 f0 00 00 00 10 00 00
[  135.962428] sd 6:0:0:0: [sdd] tag#4 uas_eh_abort_handler 0 uas-tag 5 inflight: CMD OUT 
[  135.962436] sd 6:0:0:0: [sdd] tag#4 CDB: Write(16) 8a 00 00 00 00 00 cd 40 78 00 00 00 00 f0 00 00
[  135.962567] sd 6:0:0:0: [sdd] tag#3 uas_eh_abort_handler 0 uas-tag 4 inflight: CMD OUT 
[  135.962576] sd 6:0:0:0: [sdd] tag#3 CDB: Write(16) 8a 00 00 00 00 00 cd 40 77 10 00 00 00 f0 00 00
[  135.962682] sd 6:0:0:0: [sdd] tag#2 uas_eh_abort_handler 0 uas-tag 3 inflight: CMD OUT 
[  135.962690] sd 6:0:0:0: [sdd] tag#2 CDB: Write(16) 8a 00 00 00 00 00 cd 40 76 20 00 00 00 f0 00 00
[  135.962822] sd 6:0:0:0: [sdd] tag#1 uas_eh_abort_handler 0 uas-tag 2 inflight: CMD 
[  135.962830] sd 6:0:0:0: [sdd] tag#1 CDB: Write(16) 8a 00 00 00 00 00 cd 40 75 30 00 00 00 f0 00 00
[  160.904916] sd 6:0:0:0: [sdd] tag#0 uas_eh_abort_handler 0 uas-tag 1 inflight: CMD OUT 
[  160.904926] sd 6:0:0:0: [sdd] tag#0 CDB: Write(16) 8a 00 00 00 00 00 00 00 29 08 00 00 00 08 00 00
[  160.905068] scsi host6: uas_eh_bus_reset_handler start

我在這個論壇文章上找到了這個資訊,UAS 和新的 Linux 核心有問題嗎?網際網路上的許多地方似乎都知道這個問題,USB3 + Linux 在很多情況下似乎都有問題——但對於舊核心。在更新的核心上解決這個問題的任何想法?

我的核心是:

➜  ~  uname -r 
4.2.0-16-generic

嗯,對於不同的 USB3 晶片,UAS 似乎壞了ASMedia Technology Inc.您可以在此處查看更多資訊。

我想這是我的問題,但我現在該如何解決,StarTech 擴展塢中的 USB3 實現使用的是哪個晶片?

我今天在 4.8.0 核心上遇到了這個問題。

根據this forum post它可以通過

$ echo options usb-storage quirks=357d:7788:u | sudo tee /etc/modprobe.d/blacklist_uas_357d.conf
$ sudo update-initramfs -u

並重新啟動。

我在 Mint 18 上遇到了同樣的問題,但我發現的解決方案可能適用於 *Ubuntu 15/16 以及類似的 Linux 發行版。然而,對我來說,在 dmesg 中看到 UAS 錯誤後,我很快就遇到了無法恢復的系統鎖定。

我的機箱有一個 ASMedia ASM1053 晶片,這似乎與我的核心的 UAS 模組(4.4.0-72-generic)有問題。

經過一番搜尋,我結合了我找到的兩個解決方案:這個,YtvwlD 提到的和這個

首先,您必須使用lsusb命令獲取設備的硬體 ID。一旦你這樣做了,找到你的外部/外殼/橋。它可能如下所示:

Bus 002 Device 002: ID 174c:5136 ASMedia Technology Inc. ASM1053 SATA 6Gb/s bridge

在我的例子中,ID 是174c:5136

之後,您必須在**/etc/modprobe.d/ 中創建一個文件,以便將正確的設備列入使用 UAS 的黑名單(這會導致問題),使用update-initramfs**更新 initramfs 映像,然後重新啟動以使更改生效。

$ echo options usb-storage quirks=174c:5136:u | sudo tee /etc/modprobe.d/blacklist_uas.conf
$ sudo update-initramfs -u
$ sudo reboot

當然,將“174c:5136”替換為您的網橋/機箱/外部的硬體 ID。如果正確完成,在重新啟動後連接設備時,您應該會看到來自dmesg的類似消息:

[   93.985002] usb 4-1: UAS is blacklisted for this device, using usb-storage instead

從那以後,我的機箱就沒有任何問題。

引用自:https://unix.stackexchange.com/questions/239782