badblocks 需要很长时间 - 我做错了什么?

ste*_*eds 2 linux hard-drive bad-blocks

我有一个 8TB Seagate Archive 硬盘,有一些坏扇区。不过我现在还买不起更换它。我暂时尝试用坏块“修复它”,但这需要很长时间:

# badblocks -b 4096 -nvs /dev/sdd
Checking for bad blocks in non-destructive read-write mode
From block 0 to 1953506645
Checking for bad blocks (non-destructive read-write test)
Testing with random pattern:  14.28% done, 82:45:36 elapsed. (0/0/0 errors)
Run Code Online (Sandbox Code Playgroud)

运行了3.5天,电量才达到14%。应该还需要21天。我究竟做错了什么?有可能让它跑得更快吗?

CPU 和 RAM 使用情况似乎正常。

这是 SMART 报告:

# smartctl -a /dev/sdd       
smartctl 6.6 2017-11-05 r4594 [x86_64-linux-4.18.0-2-amd64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Seagate Archive HDD
Device Model:     ST8000AS0002-1NA17Z
Serial Number:    #########
LU WWN Device Id: #########
Firmware Version: RT17
User Capacity:    8,001,563,222,016 bytes [8.00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    5980 rpm
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-2, ACS-3 T13/2161-D revision 3b
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 3.0 Gb/s)
Local Time is:    Mon Aug 12 01:58:39 2019 CEST
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:  (0x82) Offline data collection activity
                    was completed without error.
                    Auto Offline Data Collection: Enabled.
Self-test execution status:      (   0) The previous self-test routine completed
                    without error or no self-test has ever 
                    been run.
Total time to complete Offline 
data collection:        (    0) seconds.
Offline data collection
capabilities:            (0x7b) SMART execute Offline immediate.
                    Auto Offline data collection on/off support.
                    Suspend Offline collection upon new
                    command.
                    Offline surface scan supported.
                    Self-test supported.
                    Conveyance Self-test supported.
                    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:    (   1) minutes.
Extended self-test routine
recommended polling time:    ( 957) minutes.
Conveyance self-test routine
recommended polling time:    (   2) minutes.
SCT capabilities:          (0x30b5) SCT Status supported.
                    SCT Feature Control supported.
                    SCT Data Table supported.

SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000f   113   099   006    Pre-fail  Always       -       53146800
  3 Spin_Up_Time            0x0003   093   090   000    Pre-fail  Always       -       0
  4 Start_Stop_Count        0x0032   100   100   020    Old_age   Always       -       536
  5 Reallocated_Sector_Ct   0x0033   100   100   010    Pre-fail  Always       -       16
  7 Seek_Error_Rate         0x000f   061   047   030    Pre-fail  Always       -       189036925963
  9 Power_On_Hours          0x0032   078   078   000    Old_age   Always       -       19486
 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   098   098   020    Old_age   Always       -       2331
183 Runtime_Bad_Block       0x0032   100   100   000    Old_age   Always       -       0
184 End-to-End_Error        0x0032   100   100   099    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   072   072   000    Old_age   Always       -       28
188 Command_Timeout         0x0032   100   100   000    Old_age   Always       -       0
189 High_Fly_Writes         0x003a   097   097   000    Old_age   Always       -       3
190 Airflow_Temperature_Cel 0x0022   058   052   045    Old_age   Always       -       42 (Min/Max 38/45)
191 G-Sense_Error_Rate      0x0032   100   100   000    Old_age   Always       -       0
192 Power-Off_Retract_Count 0x0032   054   054   000    Old_age   Always       -       92104
193 Load_Cycle_Count        0x0032   029   029   000    Old_age   Always       -       143183
194 Temperature_Celsius     0x0022   042   048   000    Old_age   Always       -       42 (0 17 0 0 0)
195 Hardware_ECC_Recovered  0x001a   113   099   000    Old_age   Always       -       53146800
197 Current_Pending_Sector  0x0012   094   094   000    Old_age   Always       -       2168
198 Offline_Uncorrectable   0x0010   094   094   000    Old_age   Offline      -       2168
199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       -       0
240 Head_Flying_Hours       0x0000   100   253   000    Old_age   Offline      -       13141 (67 108 0)
241 Total_LBAs_Written      0x0000   100   253   000    Old_age   Offline      -       26109744918
242 Total_LBAs_Read         0x0000   100   253   000    Old_age   Offline      -       197934360042

SMART Error Log Version: 1
ATA Error Count: 28 (device log contains only the most recent five errors)
    CR = Command Register [HEX]
    FR = Features Register [HEX]
    SC = Sector Count Register [HEX]
    SN = Sector Number Register [HEX]
    CL = Cylinder Low Register [HEX]
    CH = Cylinder High Register [HEX]
    DH = Device/Head Register [HEX]
    DC = Device Command Register [HEX]
    ER = Error register [HEX]
    ST = Status register [HEX]
Powered_Up_Time is measured from power on, and printed as
DDd+hh:mm:SS.sss where DD=days, hh=hours, mm=minutes,
SS=sec, and sss=millisec. It "wraps" after 49.710 days.

Error 28 occurred at disk power-on lifetime: 19364 hours (806 days + 20 hours)
  When the command that caused the error occurred, the device was active or idle.

  After command completion occurred, registers were:
  ER ST SC SN CL CH DH
  -- -- -- -- -- -- --
  40 53 00 ff ff ff 0f  Error: UNC at LBA = 0x0fffffff = 268435455

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  60 00 00 ff ff ff 4f 00      00:50:21.805  READ FPDMA QUEUED
  60 00 00 ff ff ff 4f 00      00:50:21.805  READ FPDMA QUEUED
  60 00 00 ff ff ff 4f 00      00:50:21.805  READ FPDMA QUEUED
  60 00 00 ff ff ff 4f 00      00:50:21.804  READ FPDMA QUEUED
  60 00 00 ff ff ff 4f 00      00:50:21.804  READ FPDMA QUEUED

Error 27 occurred at disk power-on lifetime: 19364 hours (806 days + 20 hours)
  When the command that caused the error occurred, the device was active or idle.

  After command completion occurred, registers were:
  ER ST SC SN CL CH DH
  -- -- -- -- -- -- --
  40 53 00 ff ff ff 0f  Error: UNC at LBA = 0x0fffffff = 268435455

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  60 00 50 ff ff ff 4f 00      00:50:18.678  READ FPDMA QUEUED
  60 00 50 ff ff ff 4f 00      00:50:18.677  READ FPDMA QUEUED
  60 00 50 ff ff ff 4f 00      00:50:18.675  READ FPDMA QUEUED
  60 00 00 ff ff ff 4f 00      00:50:18.675  READ FPDMA QUEUED
  60 00 10 10 0a 00 40 00      00:50:18.674  READ FPDMA QUEUED

Error 26 occurred at disk power-on lifetime: 19364 hours (806 days + 20 hours)
  When the command that caused the error occurred, the device was active or idle.

  After command completion occurred, registers were:
  ER ST SC SN CL CH DH
  -- -- -- -- -- -- --
  40 53 00 ff ff ff 0f  Error: UNC at LBA = 0x0fffffff = 268435455

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  60 00 50 ff ff ff 4f 00      00:50:15.772  READ FPDMA QUEUED
  60 00 50 ff ff ff 4f 00      00:50:15.771  READ FPDMA QUEUED
  60 00 50 ff ff ff 4f 00      00:50:15.768  READ FPDMA QUEUED
  60 00 50 ff ff ff 4f 00      00:50:15.765  READ FPDMA QUEUED
  60 00 10 ff ff ff 4f 00      00:50:15.751  READ FPDMA QUEUED

Error 25 occurred at disk power-on lifetime: 19364 hours (806 days + 20 hours)
  When the command that caused the error occurred, the device was active or idle.

  After command completion occurred, registers were:
  ER ST SC SN CL CH DH
  -- -- -- -- -- -- --
  40 53 00 ff ff ff 0f  Error: UNC at LBA = 0x0fffffff = 268435455

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  60 00 50 ff ff ff 4f 00      00:50:12.728  READ FPDMA QUEUED
  60 00 00 ff ff ff 4f 00      00:50:12.727  READ FPDMA QUEUED
  60 00 00 ff ff ff 4f 00      00:50:12.726  READ FPDMA QUEUED
  60 00 00 ff ff ff 4f 00      00:50:12.724  READ FPDMA QUEUED
  60 00 00 ff ff ff 4f 00      00:50:12.723  READ FPDMA QUEUED

Error 24 occurred at disk power-on lifetime: 19364 hours (806 days + 20 hours)
  When the command that caused the error occurred, the device was active or idle.

  After command completion occurred, registers were:
  ER ST SC SN CL CH DH
  -- -- -- -- -- -- --
  40 53 00 ff ff ff 0f  Error: UNC at LBA = 0x0fffffff = 268435455

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  60 00 10 ff ff ff 4f 00      00:50:06.069  READ FPDMA QUEUED
  60 00 10 ff ff ff 4f 00      00:50:06.069  READ FPDMA QUEUED
  60 00 10 10 0a 00 40 00      00:50:06.068  READ FPDMA QUEUED
  60 00 00 ff ff ff 4f 00      00:50:06.068  READ FPDMA QUEUED
  60 00 00 ff ff ff 4f 00      00:50:06.068  READ FPDMA QUEUED

SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Extended offline    Completed: read failure       10%      9998         -
# 2  Extended offline    Interrupted (host reset)      00%      9983         -
# 3  Short offline       Completed without error       00%      2566         -
# 4  Short offline       Completed without error       00%      2431         -

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.
Run Code Online (Sandbox Code Playgroud)

我唯一能想到的是该驱动器是SATA 3 (6 Gbps),而当前安装它的计算机仅支持SATA 2 (3 Gbps)。我不认为这是问题所在,但 24 天似乎太长了。

Kam*_*ski 8

初步说明:由于Reallocated_Sector_Ct并且相当大,Current_Pending_Sector我会在尝试使用 .“修复”磁盘之前备份所有重要数据badblocks


man 8 badblocks

-b block_size
指定块的大小(以字节为单位)。默认为1024.

-c number of blocks
是一次测试的块数。默认为64.

您的选择-b是合理的:4096很可能是您设备的物理扇区大小。

你(缺乏)选择-c就远没有那么幸运了。默认值badblocks对 64 × 4096 = 256k 的块进行操作。

考虑到无损读写测试的badblocks工作原理,我声明该工具需要依次读取256k、写入256k、读取256k和写入256k到磁盘的同一区域。整个目的badblocks要求它绕过任何可以绕过的缓存;缓存,否则会优化此类操作。

从这四个动作中,第一次读取可能来自缓存,最后一次写入理论上可能会被缓存并推迟;但第一次写入操作和第二次读取操作必须与磁盘盘片进行物理交互。也许四个人都这样。写入和读取如此小的块会使整个过程变慢。

考虑-c大幅增加。我至少会选择40968192; 这些将分别给我 16M 或 32M 的块。

如果badblocks在一个物理扇区中遇到写入错误,我会期望它将数据写入该块的所有其他扇区(与丢弃整个块相反);因此只会丢失最少量的数据。无论如何,磁盘可能会重新映射有故障的扇区,因此数据不会丢失。在这种情况下,大块应该和小块一样安全。我承认我还没有测试过这个。

但是,如果发生任何严重故障(例如断电),那么您最终可能会导致整个块(或其一部分)损坏。在这种情况下,小块更安全。


如果我是你,我会考虑以下程序:

  1. 用于iotop了解当前进程的准确速度badblocks
  2. 暂停badblocks进程 ( Ctrl+ Z)。badblocks应该足够聪明,可以在块之间暂停,而不是在处理一个块的过程中暂停。
  3. 在单独的控制台中运行另一个badblocks,这次使用大型-c.
  4. 使用 监控其性能iotop
  5. 决定下一步做什么:
    • 如果新的badblocks也没有快很多:
      1. 轻轻地终止新的badblocksCtrl+ C);该工具应该足够智能,能够在块之间终止,而不是在处理块的过程中终止。
      2. 返回到旧控制台并恢复旧的badblocks( fg)。
    • 如果新的速度badblocks更快:
      1. 返回旧控制台并终止旧控制台badblocks( kill %+)。
      2. 让新badblocks工作更快。