在外部 USB HDD 上写入数据非常慢 - 即使对于大文件也是如此

在外部 USB HDD 上写入数据非常慢 - 即使对于大文件也是如此

我正在将数据复制到外部 USB HDD。数据传输非常慢。有时只有 15kB/s。
系统:
笔记本电脑:Lenovo Thinkpad L520(序列号标签:7859 - 5BG S/N LR - 9WZ84 11/09)
操作系统:Kubuntu 20.04.3
内核:5.11.0-43-generic
硬盘:Toshiba Canvio Basics 4 TB (HDTB440EK3AA)(序列号)贴纸:MSIP-REM-TSD-DTB4 DTB440)
我已使用 KDE 分区管理器将其快速格式化为 NTFS。 (分区表:GPT)

输出journalctl -xb | grep -E 'sdc|7:0:0:0'

[...] kernel: scsi 7:0:0:0: Direct-Access TOSHIBA External USB 3.0 5438 PQ: 0 ANSI: 6
[...] kernel: sd 7:0:0:0: Attached scsi generic sg3 type 0
[...] kernel: sd 7:0:0:0: [sdc] Very big device. Trying to use READ CAPACITY(16).
[...] kernel: sd 7:0:0:0: [sdc] 7814037164 512-byte logical blocks: (4.00 TB/3.64 TiB)
[...] kernel: sd 7:0:0:0: [sdc] 4096-byte physical blocks
[...] kernel: sd 7:0:0:0: [sdc] Write Protect is off
[...] kernel: sd 7:0:0:0: [sdc] Mode Sense: 23 00 00 00
[...] kernel: sd 7:0:0:0: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[...] kernel: sdc: sdc1 sdc2
[...] kernel: sd 7:0:0:0: [sdc] Attached SCSI disk
[...] kernel: sdc: sdc1
[...] kernel: sdc: sdc1
[...] kernel: sdc:
[...] kernel: sdc:
[...] kernel: sdc: sdc1
[...] kernel: sdc: sdc1
[...] ntfs-3g[68912]: Mounted /dev/sdc1 (Read-Write, label "massstorage", NTFS 3.1)
[...] ntfs-3g[68912]: Mount options: nodev,nosuid,uhelper=udisks2,allow_other,nonempty,relatime,rw,default_permissions,fsname=/dev/sdc1,blkdev,blksize=4096
[...] udisksd[627]: Mounted /dev/sdc1 at /media/alex/massstorage on behalf of uid 1000
[...] ntfs-3g[68912]: Unmounting /dev/sdc1 (massstorage)
[...] udisksd[627]: Unmounted /dev/sdc1 on behalf of uid 1000
[...] udisksd[627]: Successfully sent SCSI command SYNCHRONIZE CACHE to /dev/sdc
[...] udisksd[627]: Successfully sent SCSI command START STOP UNIT to /dev/sdc
[...] kernel: sd 7:0:0:0: [sdc] Synchronizing SCSI cache
[...] udisksd[627]: Powered off /dev/sdc - successfully wrote to sysfs path /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/remove
[...] kernel: scsi 7:0:0:0: Direct-Access TOSHIBA External USB 3.0 5438 PQ: 0 ANSI: 6
[...] kernel: sd 7:0:0:0: Attached scsi generic sg3 type 0
[...] kernel: sd 7:0:0:0: [sdc] Very big device. Trying to use READ CAPACITY(16).
[...] kernel: sd 7:0:0:0: [sdc] 7814037164 512-byte logical blocks: (4.00 TB/3.64 TiB)
[...] kernel: sd 7:0:0:0: [sdc] 4096-byte physical blocks
[...] kernel: sd 7:0:0:0: [sdc] Write Protect is off
[...] kernel: sd 7:0:0:0: [sdc] Mode Sense: 23 00 00 00
[...] kernel: sd 7:0:0:0: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[...] kernel: sdc: sdc1
[...] kernel: sd 7:0:0:0: [sdc] Attached SCSI disk
[...] sudo[71823]: alex : TTY=pts/1 ; PWD=/home/alex ; USER=root ; COMMAND=/usr/bin/mount -o async,flush /dev/sdc1 /media/alex/massstorage/
[...] ntfs-3g[71826]: Mounted /dev/sdc1 (Read-Write, label "massstorage", NTFS 3.1)
[...] ntfs-3g[71826]: Mount options: flush,allow_other,nonempty,relatime,rw,fsname=/dev/sdc1,blkdev,blksize=4096

传输率发生变化。
有时在 15kB/s 到 2MB/s 之间。然后 2 个 CPU 核心处于 100%,另外 2 个低于 20%。
有时在 15MB/s 到 28MB/s 之间。然后所有 4 个 CPU 核心都在 55% 左右。
(我已经进行了从另一个外部 HDD 复制到这个 HDD 的大部分测试。而且对于从内部 SSD 复制到这个 HDD 的测试,我也看到了相同的行为。)

我不完全确定传输速率与每个文件的大小是否存在相关性,但对于非常大的文件来说,传输速率似乎很慢。即使对于几 GB 的文件,速度也降至 15kB/s。 (我没有混淆任何东西,对于大文件来说有时确实很慢。)

当 Dolphin 向我显示它已完成复制,并且我在终端中运行同步时,仍然需要 10 多分钟才能返回。仍然有 2 个 CPU 核心处于 100%,其他 2 个低于 20%。

输出来自lsusb -t

/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/3p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M
        |__ Port 1: Dev 12, If 0, Class=Mass Storage, Driver=usb-storage, 480M
        |__ Port 2: Dev 16, If 0, Class=Mass Storage, Driver=usb-storage, 480M <-- this is where it's connected
        |__ Port 4: Dev 3, If 1, Class=Video, Driver=uvcvideo, 480M
        |__ Port 4: Dev 3, If 0, Class=Video, Driver=uvcvideo, 480M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/3p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M
        |__ Port 1: Dev 11, If 0, Class=Imaging, Driver=, 480M
        |__ Port 2: Dev 9, If 1, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 2: Dev 9, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 3: Dev 5, If 0, Class=Vendor Specific Class, Driver=, 12M
        |__ Port 4: Dev 10, If 0, Class=Hub, Driver=hub/6p, 480M

输出来自lsusb -s 16 -v

Bus 002 Device 016: ID 0480:0900 Toshiba America Inc MQ04UBF100
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.10
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0480 Toshiba America Inc
  idProduct          0x0900 MQ04UBF100
  bcdDevice            3.22
  iManufacturer           1 
  iProduct                2 
  iSerial                 3 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0020
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              500mA
    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     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0

它说 MaxPower 500mA,但硬盘上的标签说它需要 1.0A。该端口是一个黄色的 USB 2.0 端口,我认为它应该提供比 500mA 更大的功率。 (之前,我曾在普通 USB 2.0 端口上尝试过。没有区别。)

输出来自sudo smartctl -A -s on /dev/sdc

smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.11.0-43-generic] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART Enabled.

=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000b   100   100   050    Pre-fail  Always       -       0
  2 Throughput_Performance  0x0005   100   100   050    Pre-fail  Offline      -       0
  3 Spin_Up_Time            0x0027   100   100   001    Pre-fail  Always       -       5441
  4 Start_Stop_Count        0x0032   100   100   000    Old_age   Always       -       59
  5 Reallocated_Sector_Ct   0x0033   100   100   050    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000b   100   100   050    Pre-fail  Always       -       0
  8 Seek_Time_Performance   0x0005   100   100   050    Pre-fail  Offline      -       0
  9 Power_On_Hours          0x0032   100   100   000    Old_age   Always       -       41
 10 Spin_Retry_Count        0x0033   101   100   030    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       23
191 G-Sense_Error_Rate      0x0032   100   100   000    Old_age   Always       -       2
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       7
193 Load_Cycle_Count        0x0032   100   100   000    Old_age   Always       -       70
194 Temperature_Celsius     0x0022   100   100   000    Old_age   Always       -       28 (Min/Max 19/43)
196 Reallocated_Event_Count 0x0032   100   100   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   200   200   000    Old_age   Always       -       0
220 Disk_Shift              0x0002   100   100   000    Old_age   Always       -       0
222 Loaded_Hours            0x0032   100   100   000    Old_age   Always       -       25
223 Load_Retry_Count        0x0032   100   100   000    Old_age   Always       -       0
224 Load_Friction           0x0022   100   100   000    Old_age   Always       -       0
226 Load-in_Time            0x0026   100   100   000    Old_age   Always       -       273
240 Head_Flying_Hours       0x0001   100   100   001    Pre-fail  Offline      -       0

主板: 输出来自cat /proc/cpuinfo | grep "model name" && lshw | grep -A5 "Moth" && lshw | grep product | head -n1

model name      : Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
model name      : Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
model name      : Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
model name      : Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
       description: Motherboard
       product: 78595BG
       vendor: LENOVO
       physical id: 0
       version: Not Available
       serial: 1ZJJK19L10V
    product: 78595BG

当速度为 33MB/s 时(从内部 SSD 复制到 USB HDD): 输出iostat -kyx /dev/sdc 1 5

Linux 5.11.0-43-generic (alex-laptop)   2022-01-07      _x86_64_        (4 CPU)


avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           7,27    0,00   11,17   27,53    0,00   54,03

Device            r/s     rkB/s   rrqm/s  %rrqm r_await rareq-sz     w/s     wkB/s   wrqm/s  %wrqm w_await wareq-sz     d/s     dkB/s   drqm/s  %drqm d_await dareq-sz  aqu-sz  %util
sdc              0,00      0,00     0,00   0,00    0,00     0,00  298,00  35560,00  8592,00  96,65    6,61   119,33    0,00      0,00     0,00   0,00    0,00     0,00    1,97  99,20


avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           8,92    0,00   13,39   27,82    0,00   49,87

Device            r/s     rkB/s   rrqm/s  %rrqm r_await rareq-sz     w/s     wkB/s   wrqm/s  %wrqm w_await wareq-sz     d/s     dkB/s   drqm/s  %drqm d_await dareq-sz  aqu-sz  %util
sdc              0,00      0,00     0,00   0,00    0,00     0,00  295,00  35292,00  8528,00  96,66    6,82   119,63    0,00      0,00     0,00   0,00    0,00     0,00    2,01 100,80


avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           7,33    0,00   10,47   29,84    0,00   52,36

Device            r/s     rkB/s   rrqm/s  %rrqm r_await rareq-sz     w/s     wkB/s   wrqm/s  %wrqm w_await wareq-sz     d/s     dkB/s   drqm/s  %drqm d_await dareq-sz  aqu-sz  %util
sdc              0,00      0,00     0,00   0,00    0,00     0,00  247,00  29532,00  7136,00  96,65    8,08   119,56    0,00      0,00     0,00   0,00    0,00     0,00    2,00 100,00


avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          10,36    0,00   12,18   26,94    0,00   50,52

Device            r/s     rkB/s   rrqm/s  %rrqm r_await rareq-sz     w/s     wkB/s   wrqm/s  %wrqm w_await wareq-sz     d/s     dkB/s   drqm/s  %drqm d_await dareq-sz  aqu-sz  %util
sdc              0,00      0,00     0,00   0,00    0,00     0,00  276,00  33000,00  7974,00  96,65    7,16   119,57    0,00      0,00     0,00   0,00    0,00     0,00    1,98  99,20


avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           7,11    0,00   12,44   26,90    0,00   53,55

Device            r/s     rkB/s   rrqm/s  %rrqm r_await rareq-sz     w/s     wkB/s   wrqm/s  %wrqm w_await wareq-sz     d/s     dkB/s   drqm/s  %drqm d_await dareq-sz  aqu-sz  %util
sdc              0,00      0,00     0,00   0,00    0,00     0,00  285,00  34064,00  8231,00  96,65    7,06   119,52    0,00      0,00     0,00   0,00    0,00     0,00    2,01 100,80

当速度为 20kB/s 时(从内部 SSD 复制到 USB HDD): 输出iostat -kyx /dev/sdc 1 5

Linux 5.11.0-43-generic (alex-laptop)   2022-01-07      _x86_64_        (4 CPU)


avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           3,54    0,00    1,52   47,47    0,00   47,47

Device            r/s     rkB/s   rrqm/s  %rrqm r_await rareq-sz     w/s     wkB/s   wrqm/s  %wrqm w_await wareq-sz     d/s     dkB/s   drqm/s  %drqm d_await dareq-sz  aqu-sz  %util
sdc              0,00      0,00     0,00   0,00    0,00     0,00    1,00    120,00    29,00  96,67 2104,00   120,00    0,00      0,00     0,00   0,00    0,00     0,00    2,10 101,60


avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           3,78    0,00    1,51   48,11    0,00   46,60

Device            r/s     rkB/s   rrqm/s  %rrqm r_await rareq-sz     w/s     wkB/s   wrqm/s  %wrqm w_await wareq-sz     d/s     dkB/s   drqm/s  %drqm d_await dareq-sz  aqu-sz  %util
sdc              0,00      0,00     0,00   0,00    0,00     0,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00   0,00


avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           3,81    0,00    0,76   47,97    0,00   47,46

Device            r/s     rkB/s   rrqm/s  %rrqm r_await rareq-sz     w/s     wkB/s   wrqm/s  %wrqm w_await wareq-sz     d/s     dkB/s   drqm/s  %drqm d_await dareq-sz  aqu-sz  %util
sdc              0,00      0,00     0,00   0,00    0,00     0,00    1,00    120,00    29,00  96,67 2080,00   120,00    0,00      0,00     0,00   0,00    0,00     0,00    2,08 106,40


avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           6,35    0,00    1,02   45,18    0,00   47,46

Device            r/s     rkB/s   rrqm/s  %rrqm r_await rareq-sz     w/s     wkB/s   wrqm/s  %wrqm w_await wareq-sz     d/s     dkB/s   drqm/s  %drqm d_await dareq-sz  aqu-sz  %util
sdc              0,00      0,00     0,00   0,00    0,00     0,00    1,00    120,00    29,00  96,67 2181,00   120,00    0,00      0,00     0,00   0,00    0,00     0,00    2,18 111,60


avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           3,31    0,00    1,27   38,17    0,00   57,25

Device            r/s     rkB/s   rrqm/s  %rrqm r_await rareq-sz     w/s     wkB/s   wrqm/s  %wrqm w_await wareq-sz     d/s     dkB/s   drqm/s  %drqm d_await dareq-sz  aqu-sz  %util
sdc              0,00      0,00     0,00   0,00    0,00     0,00    1,00    120,00    29,00  96,67 2205,00   120,00    0,00      0,00     0,00   0,00    0,00     0,00    2,21 109,20

在我告诉 Dolphin 中止传输(从内部 SSD 复制到 USB HDD)后 4 分钟:输出iostat -kyx /dev/sdc 1 5

Linux 5.11.0-43-generic (alex-laptop)   2022-01-07      _x86_64_        (4 CPU)


avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           4,05    0,00    2,03   23,54    0,00   70,38

Device            r/s     rkB/s   rrqm/s  %rrqm r_await rareq-sz     w/s     wkB/s   wrqm/s  %wrqm w_await wareq-sz     d/s     dkB/s   drqm/s  %drqm d_await dareq-sz  aqu-sz  %util
sdc              0,00      0,00     0,00   0,00    0,00     0,00    1,00    120,00    29,00  96,67 1068,00   120,00    0,00      0,00     0,00   0,00    0,00     0,00    1,07 106,80


avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           4,52    0,00    1,01   23,62    0,00   70,85

Device            r/s     rkB/s   rrqm/s  %rrqm r_await rareq-sz     w/s     wkB/s   wrqm/s  %wrqm w_await wareq-sz     d/s     dkB/s   drqm/s  %drqm d_await dareq-sz  aqu-sz  %util
sdc              0,00      0,00     0,00   0,00    0,00     0,00    1,00    120,00    29,00  96,67 1045,00   120,00    0,00      0,00     0,00   0,00    0,00     0,00    1,04 104,40


avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           3,81    0,00    1,27   24,37    0,00   70,56

Device            r/s     rkB/s   rrqm/s  %rrqm r_await rareq-sz     w/s     wkB/s   wrqm/s  %wrqm w_await wareq-sz     d/s     dkB/s   drqm/s  %drqm d_await dareq-sz  aqu-sz  %util
sdc              0,00      0,00     0,00   0,00    0,00     0,00    1,00    120,00    29,00  96,67 1081,00   120,00    0,00      0,00     0,00   0,00    0,00     0,00    1,08 108,00


avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           4,27    0,00    1,26   23,87    0,00   70,60

Device            r/s     rkB/s   rrqm/s  %rrqm r_await rareq-sz     w/s     wkB/s   wrqm/s  %wrqm w_await wareq-sz     d/s     dkB/s   drqm/s  %drqm d_await dareq-sz  aqu-sz  %util
sdc              0,00      0,00     0,00   0,00    0,00     0,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00      0,00     0,00   0,00    0,00     0,00    0,00   0,00


avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           3,30    0,00    1,02   23,60    0,00   72,08

Device            r/s     rkB/s   rrqm/s  %rrqm r_await rareq-sz     w/s     wkB/s   wrqm/s  %wrqm w_await wareq-sz     d/s     dkB/s   drqm/s  %drqm d_await dareq-sz  aqu-sz  %util
sdc              0,00      0,00     0,00   0,00    0,00     0,00    1,00    120,00    29,00  96,67 1058,00   120,00    0,00      0,00     0,00   0,00    0,00     0,00    1,06 106,00

一周前,我遇到了系统崩溃。

ima: Error Communicating to TPM chip
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.4.0-91-generic #102-Ubuntu
Hardware name: LENOVO 78595BG/78595BG

(如果需要,我也可以提供调用跟踪。)然后我完全重新安装了 Kubuntu。从那以后我再也没有遇到过任何与TPM芯片有关的事情。 (另外,在崩溃之前,我对系统分区 /dev/sda6 进行了加密。但现在,我没有任何加密分区。)

我读这里使用 async,flush 选项挂载 fs 并执行此操作。sudo mount -o async,flush <device> <mountpoint> 之后,我成功地以 20MB/s 的速度传输了 9GB 的数据,直到传输速率再次下降。手册页告诉我,异步选项对 NTFS 文件系统没有任何影响,所以我相信,原因可能是其他原因。

相关内容