全新安装的 Linux Mint 18.2 中 SSD(SanDisk SD8TB8U5)写入速度极慢

全新安装的 Linux Mint 18.2 中 SSD(SanDisk SD8TB8U5)写入速度极慢

我最近在一台装有 2 个 SanDisk SSD 的全新 PC 上安装了 Linux Mint 18.2。安装完成且没有错误。

在这台新电脑上安装好所有需要的软件后,我注意到磁盘的性能非常慢——尤其是写入速度。例如dd显示平均 3.5MB/s

$ dd bs=1M count=256 if=/dev/zero of=test conv=fdatasync
256+0 records in
256+0 records out
268435456 bytes (268 MB, 256 MiB) copied, 61.9192 s, 4.3 MB/s

$ dd bs=1M count=256 if=/dev/urandom of=test conv=fdatasync
256+0 records in
256+0 records out
268435456 bytes (268 MB, 256 MiB) copied, 86.7794 s, 3.1 MB/s

我甚至不知道该从哪里开始诊断或修复这个问题。这台原本非常快的电脑几乎无法使用。

noatime,errors=remount-ro安装的文件系统是 ext4,并使用 中的选项进行挂载/etc/fstab

我尝试过降低/禁用高级电源管理 ( hdparm -B 254 /dev/sda),并且还在根文件系统上手动运行 TRIM ( fstrim /)。这些方法似乎都没有什么效果。

我非常有信心将 25MiB 的文件复制到与原始文件本身相同的磁盘和分区上不会花费 15 秒:

$ stat test
  File: 'test'
  Size: 26214400    Blocks: 51200      IO Block: 4096   regular file
Device: 801h/2049d  Inode: 10880436    Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/     aps)   Gid: ( 1000/     aps)
Access: 2017-10-14 15:48:24.460658106 -0500
Modify: 2017-10-14 15:37:22.577357279 -0500
Change: 2017-10-14 15:37:22.577357279 -0500
 Birth: -

$ \time -v cp test test.out
  Command being timed: "cp test test.out"
  User time (seconds): 0.03
  System time (seconds): 0.00
  Percent of CPU this job got: 0%
  Elapsed (wall clock) time (h:mm:ss or m:ss): 0:14.36
  Average shared text size (kbytes): 0
  Average unshared data size (kbytes): 0
  Average stack size (kbytes): 0
  Average total size (kbytes): 0
  Maximum resident set size (kbytes): 2188
  Average resident set size (kbytes): 0
  Major (requiring I/O) page faults: 0
  Minor (reclaiming a frame) page faults: 134
  Voluntary context switches: 1452
  Involuntary context switches: 1
  Swaps: 0
  File system inputs: 0
  File system outputs: 51200
  Socket messages sent: 0
  Socket messages received: 0
  Signals delivered: 0
  Page size (bytes): 4096
  Exit status: 0

hdparm显示以下详细信息:

$ sudo hdparm -I /dev/sda

/dev/sda:

ATA device, with non-removable media
  Model Number:       SanDisk SD8TB8U512G1001                 
  Serial Number:      165125801567        
  Firmware Revision:  X4133101
  Media Serial Num:   
  Media Manufacturer: 
  Transport:          Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
Standards:
  Used: unknown (minor revision code 0x0110) 
  Supported: 9 8 7 6 5 
  Likely used: 9
Configuration:
  Logical   max current
  cylinders 16383 0
  heads   16  0
  sectors/track 63  0
  --
  LBA    user addressable sectors:  268435455
  LBA48  user addressable sectors: 1000215216
  Logical  Sector size:                   512 bytes
  Physical Sector size:                   512 bytes
  Logical Sector-0 offset:                  0 bytes
  device size with M = 1024*1024:      488386 MBytes
  device size with M = 1000*1000:      512110 MBytes (512 GB)
  cache/buffer size  = unknown
  Form Factor: 2.5 inch
  Nominal Media Rotation Rate: Solid State Device
Capabilities:
  LBA, IORDY(can be disabled)
  Queue depth: 32
  Standby timer values: spec'd by Standard, no device specific minimum
  R/W multiple sector transfer: Max = 1 Current = 1
  Advanced power management level: 254
  DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6 
       Cycle time: min=120ns recommended=120ns
  PIO: pio0 pio1 pio2 pio3 pio4 
       Cycle time: no flow control=120ns  IORDY flow control=120ns
Commands/features:
  Enabled Supported:
     *  SMART feature set
        Security Mode feature set
     *  Power Management feature set
     *  Write cache
     *  Look-ahead
     *  WRITE_BUFFER command
     *  READ_BUFFER command
     *  DOWNLOAD_MICROCODE
     *  Advanced Power Management feature set
        SET_MAX security extension
     *  48-bit Address feature set
     *  Mandatory FLUSH_CACHE
     *  FLUSH_CACHE_EXT
     *  SMART error logging
     *  SMART self-test
     *  General Purpose Logging feature set
     *  64-bit World wide name
     *  WRITE_UNCORRECTABLE_EXT command
     *  {READ,WRITE}_DMA_EXT_GPL commands
     *  Segmented DOWNLOAD_MICROCODE
        unknown 119[8]
     *  Gen1 signaling speed (1.5Gb/s)
     *  Gen2 signaling speed (3.0Gb/s)
     *  Gen3 signaling speed (6.0Gb/s)
     *  Native Command Queueing (NCQ)
     *  Phy event counters
     *  READ_LOG_DMA_EXT equivalent to READ_LOG_EXT
     *  DMA Setup Auto-Activate optimization
        Device-initiated interface power management
     *  Software settings preservation
        Device Sleep (DEVSLP)
     *  reserved 69[4]
     *  DOWNLOAD MICROCODE DMA command
     *  WRITE BUFFER DMA command
     *  READ BUFFER DMA command
     *  Data Set Management TRIM supported (limit 8 blocks)
     *  Deterministic read ZEROs after TRIM
Security: 
  Master password revision code = 1
    supported
  not enabled
  not locked
    frozen
  not expired: security count
    supported: enhanced erase
  2min for SECURITY ERASE UNIT. 2min for ENHANCED SECURITY ERASE UNIT. 
Logical Unit WWN Device Identifier: 5001b448b48ce759
  NAA   : 5
  IEEE OUI  : 001b44
  Unique ID : 8b48ce759
Device Sleep:
  DEVSLP Exit Timeout (DETO): 30 ms (drive)
  Minimum DEVSLP Assertion Time (MDAT): 30 ms (drive)
Checksum: correct

安装在 PC 上的第二个 SSD 目前未格式化。是否可以准备另一个磁盘以解决此问题,同时保留复制到该磁盘上的当前 Mint 用户空间安装/配置?必须重新安装已在此慢速磁盘上设置的所有软件将是一场噩梦。


编辑

系统规格来自inxi

$ inxi -Fz
System:    Host: dapadev Kernel: 4.8.0-53-generic i686 (32 bit) Desktop: Cinnamon 3.4.3
           Distro: Linux Mint 18.2 Sonya
Machine:   System: LENOVO product: 30B7000YUS v: ThinkStation P710
           Mobo: LENOVO model: 1030 v: SBB0J05441 WIN 3305058809791 Bios: LENOVO v: S01KT40A date: 05/04/2017
CPU:       Octa core Intel Xeon E5-2620 v4 (-HT-MCP-) cache: 20480 KB 
           clock speeds: max: 3000 MHz 1: 2099 MHz 2: 2100 MHz 3: 2120 MHz 4: 2100 MHz 5: 2099 MHz 6: 2100 MHz
           7: 2299 MHz 8: 2100 MHz
Graphics:  Card: NVIDIA GK107GL [Quadro K420]
           Display Server: X.Org 1.18.4 drivers: nvidia (unloaded: fbdev,vesa,nouveau)
           Resolution: [email protected]
           GLX Renderer: Quadro K420/PCIe/SSE2 GLX Version: 4.5.0 NVIDIA 375.66
Audio:     Card-1 NVIDIA GK107 HDMI Audio Controller driver: snd_hda_intel Sound: ALSA v: k4.8.0-53-generic
           Card-2 Intel C610/X99 series HD Audio Controller driver: snd_hda_intel
Network:   Card-1: Intel Ethernet Connection (2) I218-LM driver: e1000e
           IF: eth0 state: up speed: 1000 Mbps duplex: full mac: <filter>
           Card-2: Intel I210 Gigabit Network Connection driver: igb
           IF: eth1 state: down mac: <filter>
           Card-3: Intel I210 Gigabit Network Connection driver: igb
           IF: eth2 state: up speed: 100 Mbps duplex: full mac: <filter>
Drives:    HDD Total Size: 2024.4GB (2.1% used) ID-1: /dev/sda model: SanDisk_SD8TB8U5 size: 512.1GB
           ID-2: /dev/sdb model: SanDisk_SD8TB8U5 size: 512.1GB ID-3: /dev/sdc model: ST1000DM003 size: 1000.2GB
Partition: ID-1: / size: 438G used: 8.9G (3%) fs: ext4 dev: /dev/sda1
           ID-2: swap-1 size: 34.24GB used: 0.00GB (0%) fs: swap dev: /dev/sda5
RAID:      No RAID devices: /proc/mdstat, md_mod kernel module present
Sensors:   System Temperatures: cpu: 43.0C mobo: N/A gpu: 53C
           Fan Speeds (in rpm): cpu: N/A
Info:      Processes: 275 Uptime: 3 days Memory: 1887.9/32323.8MB Client: Shell (bash) inxi: 2.2.35

驾车详情来自lsblk

$ lsblk -Sfalt
NAME HCTL       TYPE VENDOR   MODEL             REV TRAN   NAME FSTYPE LABEL UUID MOUNTPOINT NAME ALIGNMENT MIN-IO OPT-IO PHY-SEC LOG-SEC ROTA SCHED    RQ-SIZE  RA WSAME
sdb  3:0:0:0    disk ATA      SanDisk SD8TB8U5 3101 sata   sdb                               sdb          0    512      0     512     512    0 deadline     128 128    0B
sr0  6:0:0:0    rom  PLDS     DVD-RW DH16AFSH  DL3M sata   sr0                               sr0          0    512      0     512     512    1 deadline     128 128    0B
sdc  4:0:0:0    disk ATA      ST1000DM003-1SB1 CC62 sata   sdc                               sdc          0   4096      0    4096     512    1 deadline     128 128    0B
sda  2:0:0:0    disk ATA      SanDisk SD8TB8U5 3101 sata   sda                               sda          0    512      0     512     512    0 deadline     128 128    0B

驾车详情来自smartctl

$ sudo smartctl -a /dev/sda
smartctl 6.5 2016-01-24 r4214 [i686-linux-4.8.0-53-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     SanDisk SD8TB8U512G1001
Serial Number:    165125801567
LU WWN Device Id: 5 001b44 8b48ce759
Firmware Version: X4133101
User Capacity:    512,110,190,592 bytes [512 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
Form Factor:      2.5 inches
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   ACS-2 T13/2015-D revision 3
SATA Version is:  SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Sat Oct 14 16:05:13 2017 CDT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x00) Offline data collection activity
          was never started.
          Auto Offline Data Collection: Disabled.
Self-test execution status:      (  16) The self-test routine was aborted by
          the host.
Total time to complete Offline 
data collection:    (    0) seconds.
Offline data collection
capabilities:        (0x11) SMART execute Offline immediate.
          No Auto Offline data collection support.
          Suspend Offline collection upon new
          command.
          No Offline surface scan supported.
          Self-test supported.
          No Conveyance Self-test supported.
          No Selective Self-test supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
          power-saving mode.
          Supports SMART auto save timer.
Error logging capability:        (0x01) Error logging supported.
          General Purpose Logging supported.
Short self-test routine 
recommended polling time:    (   2) minutes.
Extended self-test routine
recommended polling time:    (  10) minutes.

SMART Attributes Data Structure revision number: 4
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  5 Reallocated_Sector_Ct   0x0032   100   100   ---    Old_age   Always       -       0
  9 Power_On_Hours          0x0032   100   100   ---    Old_age   Always       -       519
 12 Power_Cycle_Count       0x0032   100   100   ---    Old_age   Always       -       309
170 Unknown_Attribute       0x0032   100   100   ---    Old_age   Always       -       0
171 Unknown_Attribute       0x0032   100   100   ---    Old_age   Always       -       0
172 Unknown_Attribute       0x0032   100   100   ---    Old_age   Always       -       0
173 Unknown_Attribute       0x0032   100   100   ---    Old_age   Always       -       0
174 Unknown_Attribute       0x0032   100   100   ---    Old_age   Always       -       48
178 Used_Rsvd_Blk_Cnt_Chip  0x0032   100   100   ---    Old_age   Always       -       0
180 Unused_Rsvd_Blk_Cnt_Tot 0x0033   100   100   010    Pre-fail  Always       -       100
184 End-to-End_Error        0x0033   100   100   097    Pre-fail  Always       -       0
187 Reported_Uncorrect      0x0032   100   100   ---    Old_age   Always       -       0
194 Temperature_Celsius     0x0022   068   033   ---    Old_age   Always       -       32 (Min/Max 23/33)
199 UDMA_CRC_Error_Count    0x0032   100   100   ---    Old_age   Always       -       0
233 Media_Wearout_Indicator 0x0033   100   100   001    Pre-fail  Always       -       16772743
234 Unknown_Attribute       0x0032   100   100   ---    Old_age   Always       -       90
241 Total_LBAs_Written      0x0030   253   253   ---    Old_age   Offline      -       101
242 Total_LBAs_Read         0x0030   253   253   ---    Old_age   Offline      -       13
249 Unknown_Attribute       0x0032   100   100   ---    Old_age   Always       -       40

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline       Aborted by host               00%       519         -

Selective Self-tests/Logging not supported

答案1

对于那些感到疑惑的人来说,这是 Linux 内核中的一个错误,可在此处跟踪: 与 3.x 相比,4.x+/i386/16+RAM 上的磁盘写入速度慢 100 多倍

(和这里: 32位内核硬盘写入速度慢, 和这里: 正常运行一段时间后磁盘写入速度变慢,仅适用于 32 位/16+RAM/4+ 内核

它会在 32 位内核上触发,并且内存超过 12GB(8GB?)(已启用)。这显然是在内核 v4.2.0 中引入的,但尚未解决(RedHat 似乎提供了缓解补丁,但从未将其发布到上游)。

一位用户通过在命令行选项中设置此项找到了解决方法GRUB

mem=12G

(或任何低于该值)但是,正如您所猜测的,它限制了该会话中可用的内存量。

我个人觉得这个设置vm.highmem_is_dirtyable=1是可行的(当我还在使用 32 位内核时,64 位内核没有这个选项),但 Andrew Morton 说这样做可能会导致其他问题。您可以通过运行来测试它:

 sysctl -w vm.highmem_is_dirtyable=1

以下是关于该问题的精彩描述:PAE 内核导致 I/O 速度极慢

答案2

使用 SSD,您肯定会看到至少 100 MiB/s 的速度。通常更快。

对于问题的第二部分,是的,您可以将安装的确切内容复制到新磁盘。

要诊断磁盘速度慢的问题,除了其他人建议的方法外,您还可以尝试以下几种方法:

  • 查看 dmesg 中有关 sda/sdb 超时和类似信息
  • 更换电缆
  • 在另一台计算机上尝试磁盘
  • 启动不同的发行版(即 live USB)并使用不同的内核检查磁盘速度
  • 尝试使用同一根电缆、同一端口和同一发行版安装不同的 SSD
  • 运行smartctl -a以查看是否报告了可疑内容
  • 尝试blkdiscard全部擦除(一些较旧/质量较差的 SSD 可能仍会因性能下降而受到严重影响)
  • 看看是否可以更新 SSD 固件
  • 尝试制造商诊断工具

答案3

这更多的是一种权宜之计,而不是对问题的正确修复——用 Linux Mint 18.2 64 位替换 Linux Mint 18.2 32 位可以永久解决极慢的写入速度问题。


想要了解更多详情吗?亲爱的读者,请继续阅读!

我们需要使用特定的 32 位编译器工具链。因此,我认为最好安装 32 位操作系统,于是我选择了 Linux Mint Cinnamon(内核 4.8),因为我觉得对于一些不太熟悉 Linux 的开发人员来说,这是一个更适合桌面的发行版。

启动后,写入速度立即达到 200 MiB/秒以上;大约一小时后,又降到 5 MiB/秒以下。

在运行 Manjaro Linux 32 位(内核 4.9 LTS,以及一些 4.10)时观察到了完全相同的行为。

所以我尝试安装 Linux Mint 64 位(同样是 4.8 内核)。现在磁盘写入速度很快,并且保持很快;完全没有磁盘问题。这立即让我意识到这是一个内核错误,是 SSD 驱动程序之一,专门用于 32 位环境。

幸运的是,apt有一个元包ia32-libs安装了一个可靠的 x86 库集合,这几乎足以运行我们的 32 位编译器工具链 - 只需要手动安装一个额外的库。

相关内容