1.oops ~ # smartctl -H /dev/sdb

smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.3.1-gentoo] (local build)

Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===

SMART overall-health self-assessment test result: FAILED! <----result后边的结果:PASSED,这表示硬盘健康状态良好;如果这里显示Failure,那么最好立刻给服务器更换硬盘

Drive failure expected in less than 24 hours. SAVE ALL DATA.

Failed Attributes:

ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE

  5 Reallocated_Sector_Ct 0x0033 001 001 036 Pre-fail Always FAILING_NOW 4095

2.oops ~ # smartctl -C -t short /dev/sdb

smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.3.1-gentoo] (local build)

Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===

Sending command: "Execute SMART Short self-test routine immediately in captive mode".

Drive command "Execute SMART Short self-test routine immediately in captive mode" successful.

Testing has begun.

Please wait 1 minutes for test to complete.

Test will complete after Tue Nov 5 12:19:54 2013

3.oops ~ # smartctl -l selftest /dev/sdb2

smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.3.1-gentoo] (local build)

Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===

SMART Self-test log structure revision number 1

Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error

# 1 Short captive Completed: unknown failure 90% 36265 0

# 2 Short captive Completed: unknown failure 90% 36265 0

4.oops ~ # smartctl -l error /dev/sdb

smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.3.1-gentoo] (local build)

Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===

SMART Error Log Version: 1

ATA Error Count: 94 (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 94 occurred at disk power-on lifetime: 36263 hours (1510 days + 23 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

  -- -- -- -- -- -- --

  04 71 04 9d 00 32 e0 Device Fault; Error: ABRT

  Commands leading to the command that caused the error were:

  CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name

  -- -- -- -- -- -- -- -- ---------------- --------------------

  a1 00 00 00 00 00 a0 00 00:14:55.632 IDENTIFY PACKET DEVICE

  ec 00 00 00 00 00 a0 00 00:14:55.631 IDENTIFY DEVICE

  ff 00 00 00 00 00 00 00 00:14:55.480 [VENDOR SPECIFIC]

  00 00 00 00 00 00 00 04 00:14:55.480 NOP [Abort queued commands]

  ff 00 00 00 00 00 00 00 00:14:55.173 [VENDOR SPECIFIC]

Error 93 occurred at disk power-on lifetime: 36263 hours (1510 days + 23 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

  -- -- -- -- -- -- --

  04 71 04 9d 00 32 e0

  Commands leading to the command that caused the error were:

  CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name

  -- -- -- -- -- -- -- -- ---------------- --------------------

  ec 00 00 00 00 00 a0 00 00:14:55.631 IDENTIFY DEVICE

  ff 00 00 00 00 00 00 00 00:14:55.480 [VENDOR SPECIFIC]

  00 00 00 00 00 00 00 04 00:14:55.480 NOP [Abort queued commands]

  ff 00 00 00 00 00 00 00 00:14:55.173 [VENDOR SPECIFIC]

  00 00 00 00 00 00 00 ff 00:14:55.173 NOP [Abort queued commands]

Error 92 occurred at disk power-on lifetime: 36263 hours (1510 days + 23 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

  -- -- -- -- -- -- --

  04 71 04 9d 00 32 e0 Device Fault; Error: ABRT

  Commands leading to the command that caused the error were:

  CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name

  -- -- -- -- -- -- -- -- ---------------- --------------------

  a1 00 00 00 00 00 a0 00 00:14:50.171 IDENTIFY PACKET DEVICE

  ec 00 00 00 00 00 a0 00 00:14:50.171 IDENTIFY DEVICE

  ff 00 00 00 00 00 00 00 00:14:50.020 [VENDOR SPECIFIC]

  00 00 00 00 00 00 00 04 00:14:50.020 NOP [Abort queued commands]

  ff 00 00 00 00 00 00 00 00:14:49.713 [VENDOR SPECIFIC]

Error 91 occurred at disk power-on lifetime: 36263 hours (1510 days + 23 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

  -- -- -- -- -- -- --

  04 71 04 9d 00 32 e0

  Commands leading to the command that caused the error were:

  CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name

  -- -- -- -- -- -- -- -- ---------------- --------------------

  ec 00 00 00 00 00 a0 00 00:14:50.171 IDENTIFY DEVICE

  ff 00 00 00 00 00 00 00 00:14:50.020 [VENDOR SPECIFIC]

  00 00 00 00 00 00 00 04 00:14:50.020 NOP [Abort queued commands]

  ff 00 00 00 00 00 00 00 00:14:49.713 [VENDOR SPECIFIC]

  00 00 00 00 00 00 00 ff 00:14:49.713 NOP [Abort queued commands]

Error 90 occurred at disk power-on lifetime: 36263 hours (1510 days + 23 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

  -- -- -- -- -- -- --

  04 71 04 9d 00 32 e0 Device Fault; Error: ABRT

  Commands leading to the command that caused the error were:

  CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name

  -- -- -- -- -- -- -- -- ---------------- --------------------

  a1 00 00 00 00 00 a0 00 00:14:49.686 IDENTIFY PACKET DEVICE

  ec 00 00 00 00 00 a0 00 00:14:49.661 IDENTIFY DEVICE

  2f 00 01 10 00 00 a0 00 00:14:49.632 READ LOG EXT

  60 00 00 ff ff ff 4f 00 00:14:46.851 READ FPDMA QUEUED

  60 00 00 ff ff ff 4f 00 00:14:46.847 READ FPDMA QUEUED

4.smartctl -a /dev/sdb

smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.3.1-gentoo] (local build)

Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===

Model Family: Seagate Barracuda 7200.11

Device Model: ST31000333AS

Serial Number: 9TE19F5L

LU WWN Device Id: 5 000c50 010aad5e2

Firmware Version: CC1H

User Capacity: 1,000,204,886,016 bytes [1.00 TB]

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 T13/1699-D revision 4

SATA Version is: SATA 2.6, 3.0 Gb/s

Local Time is: Tue Nov 5 11:48:20 2013 CST

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: (0x82) Offline data collection activity

     was completed without error.

     Auto Offline Data Collection: Enabled.

Self-test execution status: ( 73) The previous self-test completed having

     a test element that failed and the test

     element that failed is not known.

Total time to complete Offline

data collection: ( 625) 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: ( 208) minutes.

Conveyance self-test routine

recommended polling time: ( 2) minutes.

SCT capabilities: (0x103f) SCT Status supported.

     SCT Error Recovery Control 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 116 099 006 Pre-fail Always - 114128654

  3 Spin_Up_Time 0x0003 100 100 000 Pre-fail Always - 0

  4 Start_Stop_Count 0x0032 100 100 020 Old_age Always - 85

  5 Reallocated_Sector_Ct 0x0033 001 001 036 Pre-fail Always FAILING_NOW 4095 <-------

  7 Seek_Error_Rate 0x000f 084 060 030 Pre-fail Always - 281473872

  9 Power_On_Hours 0x0032 059 059 000 Old_age Always - 36265

 10 Spin_Retry_Count 0x0013 100 100 097 Pre-fail Always - 0

 12 Power_Cycle_Count 0x0032 100 037 020 Old_age Always - 85

184 End-to-End_Error 0x0032 100 100 099 Old_age Always - 0

187 Reported_Uncorrect 0x0032 090 090 000 Old_age Always - 10

188 Command_Timeout 0x0032 100 097 000 Old_age Always - 73015558161

189 High_Fly_Writes 0x003a 001 001 000 Old_age Always - 856

190 Airflow_Temperature_Cel 0x0022 070 054 045 Old_age Always - 30 (Min/Max 23/31)

194 Temperature_Celsius 0x0022 030 046 000 Old_age Always - 30 (0 16 0 0 0)

195 Hardware_ECC_Recovered 0x001a 052 022 000 Old_age Always - 114128654

197 Current_Pending_Sector 0x0012 100 100 000 Old_age Always - 0

198 Offline_Uncorrectable 0x0010 100 100 000 Old_age Offline - 0

199 UDMA_CRC_Error_Count 0x003e 200 200 000 Old_age Always - 0

240 Head_Flying_Hours 0x0000 100 253 000 Old_age Offline - 269680996540835

241 Total_LBAs_Written 0x0000 100 253 000 Old_age Offline - 481731982

242 Total_LBAs_Read 0x0000 100 253 000 Old_age Offline - 1978196986

SMART Error Log Version: 1

ATA Error Count: 96 (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 96 occurred at disk power-on lifetime: 36265 hours (1511 days + 1 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

  -- -- -- -- -- -- --

  04 51 00 00 00 00 00 Error: ABRT

  Commands leading to the command that caused the error were:

  CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name

  -- -- -- -- -- -- -- -- ---------------- --------------------

  b0 d4 00 81 4f c2 00 00 01:51:33.197 SMART EXECUTE OFF-LINE IMMEDIATE

  b0 d0 01 00 4f c2 00 00 01:51:33.112 SMART READ DATA

  ec 00 01 00 00 00 00 00 01:51:33.102 IDENTIFY DEVICE

  ec 00 01 00 00 00 00 00 01:51:33.100 IDENTIFY DEVICE

  b0 d5 01 01 4f c2 00 00 01:49:22.563 SMART READ LOG

Error 95 occurred at disk power-on lifetime: 36265 hours (1511 days + 1 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

  -- -- -- -- -- -- --

  04 51 00 00 00 00 00 Error: ABRT

  Commands leading to the command that caused the error were:

  CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name

  -- -- -- -- -- -- -- -- ---------------- --------------------

  b0 d4 00 81 4f c2 00 00 01:48:43.940 SMART EXECUTE OFF-LINE IMMEDIATE

  b0 d0 01 00 4f c2 00 00 01:48:43.876 SMART READ DATA

  ec 00 01 00 00 00 00 00 01:48:43.866 IDENTIFY DEVICE

  ec 00 01 00 00 00 00 00 01:48:43.865 IDENTIFY DEVICE

  b0 d5 01 01 4f c2 00 00 01:45:49.010 SMART READ LOG

Error 94 occurred at disk power-on lifetime: 36263 hours (1510 days + 23 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

  -- -- -- -- -- -- --

  04 71 04 9d 00 32 e0 Device Fault; Error: ABRT

  Commands leading to the command that caused the error were:

  CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name

  -- -- -- -- -- -- -- -- ---------------- --------------------

  a1 00 00 00 00 00 a0 00 00:14:55.632 IDENTIFY PACKET DEVICE

  ec 00 00 00 00 00 a0 00 00:14:55.631 IDENTIFY DEVICE

  ff 00 00 00 00 00 00 00 00:14:55.480 [VENDOR SPECIFIC]

  00 00 00 00 00 00 00 04 00:14:55.480 NOP [Abort queued commands]

  ff 00 00 00 00 00 00 00 00:14:55.173 [VENDOR SPECIFIC]

Error 93 occurred at disk power-on lifetime: 36263 hours (1510 days + 23 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

  -- -- -- -- -- -- --

  04 71 04 9d 00 32 e0

  Commands leading to the command that caused the error were:

  CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name

  -- -- -- -- -- -- -- -- ---------------- --------------------

  ec 00 00 00 00 00 a0 00 00:14:55.631 IDENTIFY DEVICE

  ff 00 00 00 00 00 00 00 00:14:55.480 [VENDOR SPECIFIC]

  00 00 00 00 00 00 00 04 00:14:55.480 NOP [Abort queued commands]

  ff 00 00 00 00 00 00 00 00:14:55.173 [VENDOR SPECIFIC]

  00 00 00 00 00 00 00 ff 00:14:55.173 NOP [Abort queued commands]

Error 92 occurred at disk power-on lifetime: 36263 hours (1510 days + 23 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

  -- -- -- -- -- -- --

  04 71 04 9d 00 32 e0 Device Fault; Error: ABRT

  Commands leading to the command that caused the error were:

  CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name

  -- -- -- -- -- -- -- -- ---------------- --------------------

  a1 00 00 00 00 00 a0 00 00:14:50.171 IDENTIFY PACKET DEVICE

  ec 00 00 00 00 00 a0 00 00:14:50.171 IDENTIFY DEVICE

  ff 00 00 00 00 00 00 00 00:14:50.020 [VENDOR SPECIFIC]

  00 00 00 00 00 00 00 04 00:14:50.020 NOP [Abort queued commands]

  ff 00 00 00 00 00 00 00 00:14:49.713 [VENDOR SPECIFIC]

SMART Self-test log structure revision number 1

Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error

# 1 Short captive Completed: unknown failure 90% 36265 0

# 2 Short captive Completed: unknown failure 90% 36265 0

# 3 Extended offline Completed: unknown failure 90% 36265 0

# 4 Extended offline Completed: unknown failure 90% 36264 0

# 5 Extended offline Completed: unknown failure 90% 36264 0

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.

#smartctl -A /dev/sda 查看硬盘的详细信息

#smartctl -s on /dev/sda 如果没有打开SMART技术,使用该命令打开SMART技术。

#smartctl -t short /dev/sda 后台检测硬盘,消耗时间短;

#smartctl -t long /dev/sda 后台检测硬盘,消耗时间长;

#smartctl -C -t /dev/sda short前台检测硬盘,消耗时间短;

#smartctl -C -t /dev/sda long前台检测硬盘,消耗时间长。其实就是利用硬盘SMART的自检程序。

#smartctl -X /dev/sda 中断后台检测硬盘。

#smartctl -l selftest /dev/sda 显示硬盘检测日志。

#smartctl -l error /dev/sda 显示硬盘错误汇总

坏道修复

检查: smartctl -l selftest /dev/sda

卸载: umount /dev/sda*

修复: badblocks /dev/sda

badblocks -s -v -c 32 /dev/sdb

Checking blocks 0 to 976762583

Checking for bad blocks (read-only test): 0.20% done, 0:17 elapsed. (0/0/0 errors)

检测过程是可以中途终止,也可以指定区块重新开始。

sudo badblock -s -v -c 32 /dev/sd* 976762583 125637824 (注意此处结束区块在前,起始区块在后)

修复坏道

如果只是逻辑坏道,你可以

直接fsck

fsck -a /dev/sdb

或者格式化

如果是物理坏道,你需要

a.备份硬盘数据

b.删除所有硬盘分区 <--可以隔离坏块

c.根据坏块位置以及大小,估算出所占空间。然后重新分区隔离损坏部分。btw:坏道是会扩散的,所以尽可能隔离掉多些空间。

http://www.kbnix.com/2013/07/17/check_and_repari_linux_disk_bad_block

http://www.linuxidc.com/Linux/2012-07/65723.htm

2)有些坏的分区处

       #debugreiserfs /dev/sda1 | grep -i 'blocksize'

      #badblocks -n -b 4096 -o badblocksfile /dev/sda1 把坏块区标识出来

      #mkfs.reiserfs --badblocks badblocksfile /dev/sda1

      #reiserfsck --fix--fixable --badblocks badblocksfile /dev/sda1

badblocks -w是破坏性的检查

badblocks -b 4096 -c 16 /dev/sda3 -o 1.txt

1.oops ~ # badblocks -s -b 4096 -c 16 /dev/sdb1 -o bad.sdb1

Checking for bad blocks (read-only test): 13.34% done, 2:24 elapsed. (0/0/0 errors)

2.oops ~ # badblocks -s -b 4096 -c 16 /dev/sdb2 -o bad.sdb2

Checking for bad blocks (read-only test): 0.00% done, 0:22 elapsed. (0/0/0 errors)

意思就是以4k为一个block,每一个block检查16次,

将结果输入到1.txt文件,如果硬盘正常的话,1.txt是没有任何内容的,如果硬盘很大,我们可以加一个-s参数来显示进度。

http://linux.anheng.com.cn/news/html/net_admin_blog/linux_badblocks_online_fix.html

使用badblocks 可以查出坏块,然后badblocks本是具有写测试功能,我們只需要用badblocks就可以了,

因为不用向上层的文件系统提供坏道表, 所以我們在扫描坏道时,不用设置块大小参数(-b),

首先扫描坏道

badblocks -b 4096 -o /root/sdb.bad /etc/sdb

经过慢长的时间,我們得到了一个文件/root/sdb.bad :

16435904

sdb 有1个坏块

先用dd尽量备份坏块

dd if=/dev/sdb bs=4096 skip=16435904 of=/tmp/15435904.dat count=1

如果显示读取字节数是0就多试几次, 不行就可能丢失此块数据, 倒是不用担心,一般不会有太大问题.

用badblocks的写测试功能,对这些坏块进行重写(注意! -w写测试会覆盖数据):

badblocks -w -f /dev/sdb5 16435904 16435904

如果前面的操作有成功的备份/tmp/15435904.dat, 就把它写回:

dd if=/tmp/15435904.dat of=/dev/sdb seek=15435904 bs=4096 count=1

其实我們不需要等待badblocks扫描完成, 就可以进行修复。

badblocks是对块设备进行处理, 所以可以实现对挂载中的系统进行处理。

数据比硬盘值钱, 这只可以作为临时措施,出现坏道, 还是应该换硬盘,现在硬盘不贵。

在修复前后,利用smartctl 对磁盘进行long测试的2次结果如下:

web:~# smartctl -l selftest /dev/sdb

smartctl version 5.38 [x86_64-unknown-linux-gnu] Copyright (C) 2002-8 Bruce Allen

Home page is http://smartmontools.sourceforge.net/

=== START OF READ SMART DATA SECTION ===

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% 8308 -

# 2 Short offline Completed: read failure 10% 8292 234908935

#2是修复前的测试 在234908935处出现读错误。

#1是修复后的情况没有错误

上面是对硬盘的坏块逐块进行修复的方式

当然可以写一个脚本把这些命令联起来, badblocks 也可以连续覆盖修复坏块 ,2个块号的参数, 后面一个是要覆盖的开始块数,前面一个是结束块数.

用smartctl对硬盘进行测试的方法如下

在线快速测试: 大约2分钟

smartctl -t short /dev/sdb

在线长测试: (1T大约4小时)

smartctl -t long /dev/sdb

此外还有几种测试模式:offline, short, long, conveyance, select,M-N, pending,N, afterselect,[on|off], scttempint,N[,p]

终止正在进行的测试

smartctl -X /dev/sdb

在测试结束后获取测试结果:

smatrctl -l selftest /dev/sdb

备份坏硬盘的整盘数据:

如果用dd来备份坏硬盘的整盘数据, 千万记住要增加 conv=noerror,sync 参数, noerror是遇到读错误继续, sync是用0填充错误的数据, 否则会造成数据错位, 硬盘映像就毁了。

最好是用dd_rescue来做硬盘的dump, 能显示当前的dump速度和平均速度。据说它还可以随时终止, 并再次继续,可以反向的做数据dump, 从磁盘的尾部向前dump。

在debian下,安装ddrescue软件包, 就可以执行dd_rescue了:

dd_rescue /dev/sdb /home/sdb.dump

在debian的新发行版中, 已经没有dd_rescue 换成了myrescue 用法一样

200003504

.....

240258229

(240258229-200003504)*512=20610419200b=20.61G

oops ~ # fdisk -l

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes, 1953525168 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: 0x119af6ec

Device Boot Start End Blocks Id System

/dev/sdb1 * 2048 31459327 15728640 83 Linux

/dev/sdb2 31459328 1953525167 961032920 83 Linux

# dmesg |grep error

[14800.929308] end_request: I/O error, dev sdb, sector 1953525080

[14800.929364] end_request: I/O error, dev sdb, sector 1953525088

[14800.929423] end_request: I/O error, dev sdb, sector 1953525096

[14800.929479] end_request: I/O error, dev sdb, sector 1953525104

[14800.929535] end_request: I/O error, dev sdb, sector 1953525112

[14800.929592] end_request: I/O error, dev sdb, sector 1953525120

[14800.929648] end_request: I/O error, dev sdb, sector 1953525128

[14800.929707] end_request: I/O error, dev sdb, sector 1953525136

[14800.929762] end_request: I/O error, dev sdb, sector 1953525144

[14800.929819] end_request: I/O error, dev sdb, sector 1953525152

[14800.929876] end_request: I/O error, dev sdb, sector 1953525160

2013-11-06

debugfs: open /dev/sdb2

/dev/sdb2: Can't read an inode bitmap while reading inode bitmap

读写速度测试

一.写速度测试

oops /test/nat # time dd if=/dev/zero of=/test/nat/test bs=2k count=1000000

1000000+0 records in1000000+0 records out2048000000 bytes (2.0 GB) copied, 29.6383 s, 69.1 MB/s

real 0m29.683s

user 0m0.186s

sys 0m4.672s

二.读速度测试

oops /test/nat # time dd if=/test/nat/test of=/dev/null bs=2k1000000+0 records in1000000+0 records out2048000000 bytes (2.0 GB) copied, 1.41538 s, 1.4 GB/sreal 0m1.417suser 0m0.135s

sys 0m1.282s