2011年8月アーカイブ

サーバマシンのrootから以下のメールが来た。
Subject: SMART error (CurrentPendingSector) detected on host: sv.wizard-limit.net

This email was generated by the smartd daemon running on:

   host name: sv.wizard-limit.net
  DNS domain: wizard-limit.net
  NIS domain: 

The following warning/error was logged by the smartd daemon:

Device: /dev/ad4, 1 Currently unreadable (pending) sectors


For details see host's SYSLOG (default: /var/log/messages).

You can also use the smartctl utility for further investigation.
No additional email messages about this problem will be sent.
何事かと思って /var/log/messagesを見ると、
Aug  1 08:21:28 sv smartd[1729]: Device: /dev/ad4, 1 Currently unreadable (pending) sectors
Aug  1 08:51:28 sv smartd[1729]: Device: /dev/ad4, 1 Currently unreadable (pending) sectors
Aug  1 09:21:28 sv smartd[1729]: Device: /dev/ad4, 1 Currently unreadable (pending) sectors
Aug  1 09:51:28 sv smartd[1729]: Device: /dev/ad4, 1 Currently unreadable (pending) sectors
Aug  1 10:21:28 sv smartd[1729]: Device: /dev/ad4, 1 Currently unreadable (pending) sectors
Aug  1 10:51:28 sv smartd[1729]: Device: /dev/ad4, 1 Currently unreadable (pending) sectors
Aug  1 11:21:28 sv smartd[1729]: Device: /dev/ad4, 1 Currently unreadable (pending) sectors
Aug  1 11:51:28 sv smartd[1729]: Device: /dev/ad4, 1 Currently unreadable (pending) sectors
と30分毎にエラーが出ている。エラーメッセージでぐぐると、smartd での sector error 復活作業 | ni kvelとかホームメイト21 - Fedoraの不良セクターの修復と言うページを発見。
# smartctl -t short /dev/ad4
smartctl 5.39 2009-12-09 r2995 [FreeBSD 8.2-STABLE i386] (local build)
Copyright (C) 2002-9 by Bruce Allen, 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 2 minutes for test to complete.
Test will complete after Wed Aug  3 04:28:25 2011

Use smartctl -X to abort test.

・・・2分待つ

# smartctl -l selftest /dev/ad4
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       20%     20573         424257195
ここまでは見つけたサイトと一緒。うちの場合は、424257195にエラーセクタがあると言うことなんだろう。
しかし、その後の
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
の計算式の意味がわからないのと、なんでddで/dev/zeroを書くと修復になるのかがわからなかった。恐らく、read errorが出るところに書きこむことで、不良セクタとしてマークして代替セクタを割り当ててくれる的な話か?
とりあえず、FreeBSDの場合は fdisk -luとかでは情報が出ないので、disklabelで見てみる。
# disklabel  -A /dev/ad4s1
# /dev/ad4s1:
type: ESDI
disk: ad4s1
label: 
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 60801
sectors/unit: 976773168
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0           # milliseconds
track-to-track seek: 0  # milliseconds
drivedata: 0 

8 partitions:
#          size     offset    fstype   [fsize bsize bps/cpg]
  a:    1048576          0    4.2BSD     2048 16384     8
  b:    4194304    1048576      swap                    
  c:  976768002          0    unused        0     0     # "raw" part, don't edit
  d:  268435456    5242880    4.2BSD     2048 16384 28552
  e:  703089666  273678336    4.2BSD     2048 16384 28552
disklabel: partition c doesn't cover the whole unit!
disklabel: An incorrect partition c may cause problems for standard system utilities
たぶん、上の式に出てくる512と言うのはdisklabel -Aで出てきた bytes/sector なんだろう。そして、B が bsize で16384、Sは/dev/ad4s1cを指定するならば0で良いと思われる。すると、b = (424257195 - 0) * 512 / 16384 = 13258037?
しかし、稼働中のシステムの一部にddで0を書きこむなんて怖くてできないので、代わりのHDDを買ってきてシステムを移行してから試すことにしよう。
ちなみに、前回HDDを交換したのは2009年の3月のようだ。2年半とするとちょっと寿命が短いなあ。

こう言ったメンテナンスとか、毎月の電気代、UPSのバッテリー代などを考えると、自宅サーバを続けるよりもVPSに移行した方が良いんじゃないかと最近考える。
ちょっと調べてみたけど、メジャーなところではさくらのVPSかDTIのServersManと言うのがあるらしい。
さくらの方はFreeBSDが選べるけど、HDDが少なくてIPv4のみ。DTIの方は10G/100円でHDDが追加できて、IPv6もついてくる。ただし、ドメインをDTIでやっていないと逆引きの設定ができないのと、FreeBSDが選べない。
とりあえずDTIの方は最低契約期間の縛りがなくて、最大2ヶ月無料なので、一度どんなもんか見てみても良いかも知れない。
smartのエラーが出てしまったので、HDDを交換することにする。
早速、amazonで新しいHDDとSATAケーブルを注文した。
で、HDDが届いたので、エラーが出始めているHDDと交換するためにケースを開けると、SATAの口は開いているけど、電源ケーブルが1本のケーブルに口が2つあるタイプだった。
どう見ても入りそうになかったので、現在は使用していない3.5インチのFDDを外して、代わりに新しいdiskを入れる。
既存のHDDはSATAの1番目に刺さっていたので、後のことを考えて新しいHDDをSATAの1番目に、古いHDDをSATAの2番目に繋いだ。
そして、用意しておいたKNOPPIXのCD-Rで起動することに。boot時に knoppix noswap を指定するようにとの指示を何箇所かで見たんだけど、エラーになっていたので気にせずデフォルトで起動してしまった。(後で、swapon -l とかで見ても何も出なかったので、たぶん問題ないだろう)
ちなみに、knoppixはKNOPPIX Japanese editionからknoppix_v6.4.4CD_20110130-20110301.isoを持ってきた。(ツールの方も、dd_rescueの他にddrescueとかdd_rhelpとかいろいろあるみたいだけど、なんとなくdd_rescueにした)
で、なんかGUIが起動したんだけど、ディスプレイとの相性が悪かったのかまともに表示されなくて使えない。
しょうがないので、Ctrl + Alt + F1を押してコンソールを表示して、そこで作業することにする。
ls /dev/sd* とかやると、/dev/sda と、/dev/sdb そして /dev/sdb1, /dev/sdb2, ... と表示されたので、狙い通り新しいHDDが/dev/sda, 古いHDDが/dev/sdbになったようだ。
後は、dd_rescueの実行。オプションなしで実行すると、ヘルプが出るので、適当に読んだところたぶん-Aオプション(読めなかったら0で埋める)を指定すればいいだろう。
# dd_rescue -A /dev/sdb /dev/sda
dd_rescue: (info): ipos: 488386584.0k, opos: 488386584.0k, xfrerd: 488386584.0k
                   errs:      0, errxfer:          0.0k, succxfer: 488386584.0k
             +curr.rate:    21883kB/s, avg.rate:     39190kB/s, avg.load: 15.9%
Summary for /dev/sdb -> /dev/sda:
dd_rescue: (info): ipos: 488386584.0k, opos: 488386584.0k, xfrerd: 488386584.0k
                   errs:      0, errxfer:          0.0k, succxfer: 488386584.0k
             +curr.rate:      601kB/s, avg.rate:     39190kB/s, avg.load: 15.9%
500GBのHDDのコピーに、だいたい4時間くらいかかったか。(途中で外出したので、正確な時間はわからない)
結局、コピー中にはエラーが出なかったので、古いdiskも再度newfsか何かしてやれば使えるんじゃないかと思う。
knoppix上でshutdown -r とすると、CD-Rがイジェクトされて、ENTER押さないと2分で再起動するよとか言われるので、CDを取り出してENTERを押すと、無事に新しいHDDからFreeBSDが起動した。
dmesgを見ると、新しいHDDが/dev/ad4, 古いHDDが/dev/ad6として認識されていた。(以前は、古いHDDが/dev/ad4)

さて、これで古いHDDがmountされない状態で起動するようになったので、ddによる修復を試みて見よう。
b = (int)((L-S)*512/B) を計算すると、13258037になっていたので、まずは該当のブロックを読んでみる。
# dd if=/dev/ad6 of=ad6 bs=16384 count=1 skip=13258037
1+0 records in
1+0 records out
16384 bytes transferred in 0.973938 secs (16822 bytes/sec)
んで、/dev/zeroを書く代わりにこのデータを書き戻してみる。
# dd if=ad6 of=/dev/ad6 bs=16384 count=1 seek=13258037
1+0 records in
1+0 records out
16384 bytes transferred in 0.000354 secs (46275742 bytes/sec)
すると、/var/log/messagesに以下のメッセージが出た。
Aug  5 21:13:41 sv kernel: GEOM: ad6s1: geometry does not match label (255h,63s != 16h,63s).
なんか間違ってしまったような気もするけど、今の知識では良くわからない。
気を取り直して、smartctlでテストを実行する。
# smartctl  -t long /dev/ad6
smartctl 5.39 2009-12-09 r2995 [FreeBSD 8.2-STABLE i386] (local build)
Copyright (C) 2002-9 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Execute SMART Extended self-test routine immediately in off-line mode".
Drive command "Execute SMART Extended self-test routine immediately in off-line mode" successful.
Testing has begun.
Please wait 107 minutes for test to complete.
Test will complete after Fri Aug  5 23:04:04 2011

Use smartctl -X to abort test.
後は、テストが終わったらログを確認してみよう。
2011年8月
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      

このアーカイブについて

このページには、2011年8月に書かれたブログ記事が新しい順に公開されています。

前のアーカイブは2011年7月です。

次のアーカイブは2011年10月です。

最近のコンテンツはインデックスページで見られます。過去に書かれたものはアーカイブのページで見られます。

Powered by Movable Type 6.1.1