ni kvel

漠然的な Something を Do しちゃうところ。

smartd での sector error 復活作業


without comments


家鯖で、Sector Read Error がでていて OS が立ち上がらなかったので、新規に Logical Volume 作って、一旦余っている領域から Logical Volume つくって rsync で同期後立ち上げなおした。
で、復旧後、smartd.log を見ると、家鯖の HDD で smard から↓のような悲鳴があがってた。

smartd[2684]: Device: /dev/sda, 1 Currently unreadable (pending) sectors
smartd[2684]: Device: /dev/sda, 1 Offline uncorrectable sectors

エラー箇所を調べるため、smartctl を実行

# smartctl –test=short /dev/sda
smartctl version 5.38 [i386-redhat-linux-gnu] Copyright (C) 2002-8 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: “Execute SMART Short self-test routine immediately in off-line mode”.
Drive command “Execute SMART Short self-test routine immediately in off-line mode” successful.
Testing has begun.
Please wait 1 minutes for test to complete.
Test will complete after Sun Oct 19 01:30:18 2008

んで、状況をみるために、smartctrl -l /dev/sda をやってみる。

# smartctl -l /dev/sda
smartctl version 5.38 [i386-redhat-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: read failure 90% 261 98652487

デテキターーーーーーーーーー。
ということで、早速このセクタを直す作業にはいってみる。

LBA_of_first_error の番地が 98652487 なので、↓の公式を元に dd で Zero を埋める場所(seek する場所)を見つける。

b = (int)((L-S)*512/B)
where:
b = File System block number
B = File system block size in bytes
L = LBA of bad sector
S = Starting sector of partition as shown by fdisk -lu
and (int) denotes the integer part.

今回は S の値は無しで B = 4096 L = 98652487 となるので、

b = (int)(98652487 * 512 / 4096) = (int)12331560.875 = 12331560
※ 小数点は切り捨て

となった。dd にて seek 場所が 12331560 とわかったので、早速 dd

# dd if=/dev/zero of=/dev/sda bs=4096 count=1 seek=12331560
1+0 records in
1+0 records out
4096 bytes (4.1 kB) copied, 0.000270448 s, 43.8 MB/s

そして、正常にもどったかどうかチェック!

# smartctl –test=long /dev/sda
# smarctl -l selftest /dev/sda
SMART Self-test log structure revision number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Extended offline Self-test routine in progress 90% 268 -
# 2 Extended offline Completed without error 00% 263 -
# 5 Short offline Completed: read failure 90% 261 98652487

ナオッターーーーーーーーーーーーーーー!!!!
念のため、xfs_repair してあげてから lvm logical volume なので、lvremove を使って使っていた論理ボリューム削除しました。これで再利用できるっ!!1!!

Written by miroq

10月 19th, 2008 at 1:55 am

Leave a Reply