web-dev-qa-db-ja.com

/ dev / zeroから/ dev / sdaへのddは、ディスク全体を上書きしません

ハードディスクをゼロにするためにddコマンドを発行しました。コマンドは正常に完了しましたが、ハードドライブの一部のみが上書きされました。

mint@mint ~ $ Sudo dd if=/dev/zero of=/dev/sda
dd: writing to ‘/dev/sda’: Input/output error
258416001+0 records in
258416000+0 records out
132308992000 bytes (132 GB) copied, 3741.09 s, 35.4 MB/s

以下に、ハードドライブの構成を示します。

mint@mint ~ $ Sudo fdisk -l /dev/sda
Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x8f45867a

Device Boot      Start         End      Blocks   Id  System

ノート:

  1. Ddコマンドを発行した後、パーティションテーブルを再作成しました。そのため、パーティションテーブルが表示されます。
  2. ハードドライブに不良セクタがあり、そのうち200が保留状態です。これらの不良セクタの再割り当てを強制するためにddコマンドを発行しました。
  3. 書き込み速度は34MB/sと良いようですので、ディスクの摩耗した部分を超えたパーティションにLinuxをインストールしたいと思います。貴重なデータをハードディスクに保存する予定がないので、データの損失は気にしません。
  4. 不良セクタにもかかわらず、ddコマンドはI/Oエラーを引き起こしませんでした。

smartctl出力:

mint@mint ~ $ Sudo smartctl -a /dev/sda 
smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-37-generic] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Western Digital Scorpio Black
Device Model:     WDC WD3200BEKT-75PVMT0
Serial Number:    WD-WXC1A2127646
LU WWN Device Id: 5 0014ee 6abb45855
Firmware Version: 01.01A01
User Capacity:    320,072,933,376 bytes [320 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    7200 rpm
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ATA8-ACS (minor revision not indicated)
SATA Version is:  SATA 2.6, 3.0 Gb/s
Local Time is:    Sat Jun 13 05:27:23 2015 UTC
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: FAILED!
Drive failure expected in less than 24 hours. SAVE ALL DATA.
See vendor-specific Attribute list for failed Attributes.

General SMART Values:
Offline data collection status:  (0x00) Offline data collection activity
                    was never started.
                    Auto Offline Data Collection: Disabled.
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:        ( 5760) 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:    (   2) minutes.
Extended self-test routine
recommended polling time:    (  60) minutes.
Conveyance self-test routine
recommended polling time:    (   5) minutes.
SCT capabilities:          (0x7035) SCT Status supported.
                    SCT Feature Control supported.
                    SCT Data Table supported.

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     0x002f   200   200   051    Pre-fail  Always       -       0
  3 Spin_Up_Time            0x0027   163   160   021    Pre-fail  Always       -       816
  4 Start_Stop_Count        0x0032   099   099   000    Old_age   Always       -       1156
  5 Reallocated_Sector_Ct   0x0033   133   133   140    Pre-fail  Always   FAILING_NOW 561
  7 Seek_Error_Rate         0x002e   100   253   000    Old_age   Always       -       0
  9 Power_On_Hours          0x0032   073   073   000    Old_age   Always       -       19736
 10 Spin_Retry_Count        0x0032   100   100   000    Old_age   Always       -       0
 11 Calibration_Retry_Count 0x0032   100   100   000    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   099   099   000    Old_age   Always       -       1151
191 G-Sense_Error_Rate      0x0032   001   001   000    Old_age   Always       -       2733
192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       -       64
193 Load_Cycle_Count        0x0032   137   137   000    Old_age   Always       -       191394
194 Temperature_Celsius     0x0022   105   090   000    Old_age   Always       -       38
196 Reallocated_Event_Count 0x0032   194   194   000    Old_age   Always       -       6
197 Current_Pending_Sector  0x0032   200   200   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   100   253   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   200   200   000    Old_age   Always       -       0
200 Multi_Zone_Error_Rate   0x0008   100   253   000    Old_age   Offline      -       0
240 Head_Flying_Hours       0x0032   074   074   000    Old_age   Always       -       19078
241 Total_LBAs_Written      0x0032   200   200   000    Old_age   Always       -       37643305479
242 Total_LBAs_Read         0x0032   200   200   000    Old_age   Always       -       31320890404
254 Free_Fall_Sensor        0x0032   197   197   000    Old_age   Always       -       3

SMART Error Log Version: 1
ATA Error Count: 48 (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 48 occurred at disk power-on lifetime: 19723 hours (821 days + 19 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
  -- -- -- -- -- -- --
  01 51 08 81 1d 67 ef  Error: AMNF 8 sectors at LBA = 0x0f671d81 = 258416001

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  c8 00 08 80 1d 67 ef 00      00:36:32.852  READ DMA
  ef 10 02 00 00 00 a0 00      00:36:32.852  SET FEATURES [Enable SATA feature]
  ec 00 00 00 00 00 a0 00      00:36:32.850  IDENTIFY DEVICE
  ef 03 46 00 00 00 a0 00      00:36:32.850  SET FEATURES [Set transfer mode]

Error 47 occurred at disk power-on lifetime: 19723 hours (821 days + 19 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 51 08 81 1d 67 ef  Error: UNC 8 sectors at LBA = 0x0f671d81 = 258416001

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  c8 00 08 80 1d 67 ef 00      00:36:31.120  READ DMA
  ef 10 02 00 00 00 a0 00      00:36:31.119  SET FEATURES [Enable SATA feature]
  ec 00 00 00 00 00 a0 00      00:36:31.118  IDENTIFY DEVICE
  ef 03 46 00 00 00 a0 00      00:36:31.118  SET FEATURES [Set transfer mode]

Error 46 occurred at disk power-on lifetime: 19723 hours (821 days + 19 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 51 08 81 1d 67 ef  Error: UNC 8 sectors at LBA = 0x0f671d81 = 258416001

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  c8 00 08 80 1d 67 ef 00      00:36:29.389  READ DMA
  ef 10 02 00 00 00 a0 00      00:36:29.389  SET FEATURES [Enable SATA feature]
  ec 00 00 00 00 00 a0 00      00:36:29.387  IDENTIFY DEVICE
  ef 03 46 00 00 00 a0 00      00:36:29.387  SET FEATURES [Set transfer mode]

Error 45 occurred at disk power-on lifetime: 19723 hours (821 days + 19 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 51 08 81 1d 67 ef  Error: UNC 8 sectors at LBA = 0x0f671d81 = 258416001

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  c8 00 08 80 1d 67 ef 00      00:36:27.657  READ DMA
  ef 10 02 00 00 00 a0 00      00:36:27.657  SET FEATURES [Enable SATA feature]
  ec 00 00 00 00 00 a0 00      00:36:27.655  IDENTIFY DEVICE
  ef 03 46 00 00 00 a0 00      00:36:27.655  SET FEATURES [Set transfer mode]

Error 44 occurred at disk power-on lifetime: 19723 hours (821 days + 19 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 51 08 81 1d 67 ef  Error: UNC 8 sectors at LBA = 0x0f671d81 = 258416001

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  c8 00 08 80 1d 67 ef 00      00:36:25.926  READ DMA
  ef 10 02 00 00 00 a0 00      00:36:25.926  SET FEATURES [Enable SATA feature]
  ec 00 00 00 00 00 a0 00      00:36:25.924  IDENTIFY DEVICE
  ef 03 46 00 00 00 a0 00      00:36:25.924  SET FEATURES [Set transfer mode]

SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline       Completed without error       00%         8         -
# 2  Short offline       Completed without error       00%         8         -
# 3  Short offline       Completed without error       00%         8         -
# 4  Short offline       Completed without error       00%         8         -
# 5  Short offline       Completed without error       00%         8         -
# 6  Short offline       Completed without error       00%         8         -
# 7  Short offline       Completed without error       00%         7         -
# 8  Short offline       Completed without error       00%         7         -
# 9  Short offline       Completed without error       00%         1         -
#10  Short offline       Completed without error       00%         1         -
#11  Short offline       Completed without error       00%         1         -
#12  Short offline       Completed without error       00%         1         -
#13  Short offline       Completed without error       00%         1         -
#14  Short offline       Completed without error       00%         1         -
#15  Short offline       Completed without error       00%         1         -
#16  Short offline       Completed without error       00%         1         -

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.
2
Tarik

dd出力は、I/Oエラーが発生したことを明確に示しています。おそらく、基盤となるディスクがスペアセクターを再割り当てできないか、回復不能な方法で障害が発生しました(例:SATAリンクが失われました)。

次のコマンドを発行して、ddrescueを試してみてください:ddrescue /dev/zero /dev/sda -f -D。それは何かを変えますか?

7
shodanshok

書き込みがキャッシュを通過するために同じことが起こるのを見てきました。 ddは、デフォルトでwriteシステムコールを一度に512バイト実行します。これは、4096バイトのブロックで動作するキャッシュレイヤーを通過します。ただし、基盤となるメディアは依然として512バイトのセクターを使用します。

したがって、ddwriteシステムコールを実行すると、カーネルは512バイトを変更して書き戻すために、ディスクから4096バイトのブロックをロードします。これが発生した場合、失敗するのは読み取りステップであるため、カーネルは書き込みステップに到達しません。

私が回避している方法は、キャッシュをバイパスすることです。 oflag=directを指定すると、書き込み操作のキャッシュレイヤーがバイパスされます。これによりパフォーマンスが大幅に低下する可能性があるため、seek=(offset)とcount=1を使用して単一の不良セクタを書き込むためにのみ使用しました。

8
kasperd

Ddにエラーを無視させるには:

dd if=/dev/zero of=/dev/sda conv=noerror,sync

または、この動作をデフォルトとして持つddrescueを使用します。

3