![]() |
disk に badblock が発生した場合の復旧方法を記述しますが、 この方法で disk が repair できなかったとか、余計コワレた とかゆわれても責任負えませんので、そのおつもりで。
ls とかの disk を読み書きする系のコマンドを実行した
時なんかにレスポンスがヤケに悪い・・・・とか思った
コトはありませんか?
3 分クライすると、実行結果が出力されるけど、どーした
のだろーミタイな?
そんなときは、大体、
根本的な対処は disk を新品に交換するしかないのでつが、 予算の都合や諸般の事情で買い換えられない場合に一時シノギ 程度にはイケる方法でつ。
console に表示される場合もありまつが、 log にも出ていまつ。
まずは、状況確認で dmesg で見てみましょう。
Mar 6 11:31:12 hoge scsi: [ID 107833 kern.notice]Vendor: ATASerial Number: Mar 6 11:31:12 hoge scsi: [ID 107833 kern.notice]Sense Key: Hardware Error Mar 6 11:31:12 hoge scsi: [ID 107833 kern.notice]ASC: 0x8 (LUN communication time-out), ASCQ: 0x1, FRU: 0x0 Mar 6 11:31:47 hoge scsi: [ID 107833 kern.warning] WARNING: /pci@1f,0/pci@1/scsi@4/sd@8,0 (sd8): Mar 6 11:31:47 hogeError for Command: read(10)Error Level: Retryable Mar 6 11:31:47 hoge scsi: [ID 107833 kern.notice]Requested Block: 365371136 Error Block: 365371136 |
こんなログが出てたら、
で、badblock を示す部分は、
Mar 6 11:31:47 hoge scsi: [ID 107833 kern.notice]Requested Block: 365371136 Error Block: 365371136 |
の、Error Block: 365371136 とかってアタリ。
この Error Block が badblock の absolute block number になるので、
メモってをくとかして下さい。
この情報は、 dmesg コマンドで見れますが、 /var/adm/messages にも吐き出されて
いるので、そっちを見てもヨイでつ。
absolute block number をメモってもヨイでつが、大量に出ている場合は、
/var/adm/messages を cp して vi で Error Block number だけを切り出してもヨイ
かもしれませんね。
badblock が特定できたら、あとは、カンタン。
super-user になって format を動かしてくらさい。
まずは、 format の起動からドライブの選択まで。
今回は、 c1t8d0s0 に badblock が発生したので、「1」を
選択していまつ。
# format Searching for disks...done AVAILABLE DISK SELECTIONS: 0. c0t0d0 <ST360021A cyl 28731 alt 2 hd 16 sec 255> /pci@1f,0/pci@1,1/ide@3/dad@0,0 1. c1t8d0 <ATA-OEM400--3.03 cyl 65533 alt 2 hd 189 sec 63> /pci@1f,0/pci@1/scsi@4/sd@8,0 Specify disk (enter its number): 1 ← badblock の発生ドライブを選択 selecting c1t8d0 [disk formatted] /dev/dsk/c1t8d0s0 is part of active ZFS pool zpool. Please see zpool(1M). /dev/dsk/c1t8d0s2 is part of active ZFS pool zpool. Please see zpool(1M). |
で、ドライブを選択したら format Menu がでまつ。
badblock が存在しているドライブを選択すると、 format Menu が
表示されるまでエライ時間がかかる場合がありまつ。
SCSI イニシエータが諦めるまで大人しく待つしかないでつ。
で、 format Menu から repair を選択しまつ。
FORMAT MENU: disk- select a disk type- select (define) a disk type partition- select (define) a partition table current- describe the current disk format- format and analyze the disk repair- repair a defective sector label- write label to the disk analyze- surface analysis defect- defect list management backup- search for backup labels verify- read and display labels save- save new disk/partition definitions inquiry- show vendor, product and revision volname- set 8-character volume name !<cmd>- execute <cmd>, then return quit format>repair ←repair を入力 |
repair を選択すると、badblock を指定しまつ。
Enter absolute block number of defect: 225572480 ← dmesg で調べた absolute block number を指定。 Repair is in a partition which is currently in use. Ready to repair defect, continue? y Repairing block 225572480 (18944/99/35)...ok. format> q |
badblock が複数個あるなら、 format Menu に戻ったところで、
再び repair を入力して繰り返して下さい。
ちょっとメンドイね。
badblock が 1 つや 2 つならインタラクティヴ・モードで手作業で Fix していってもヨイのでつが、20 個も 30 個も badblock を fix しよーものなら、
ミタイな。
なので、 command-file を作ってイッキにやってしまいましょう。
badblock の block number は、 dmesg か、 /var/adm/messages を
元にするのがヨイでしょう。
今回は、 dmesg を元にしまつ。
まずは、 dmesg を テキストファイルにしまつ。
とゆっても、stdio をファイルにリダイレクトするだけでつが(^^;)
# dmesg >> tmp.txt |
リダイレクト先の tmp.txt はお好きなファイル名で。 dmesg の出力が全てリダイレクトされるので、必要な Block Number のとこだけ残して後は消しまつ。 disk の error の他にも沢山メッセージが含まれているので、 grep かけて "Requested Block:" のある行だけ抜き出して さらにリダイレクトするのがラクかも。
# grep Requested tmp.txt >> badblock |
これで badblock number を含む行のみになっているハヅ。
しかし、 "Error Block:" が含まれていまつ。後、
"Requested Block:" ももういらないよね。
vi で ファイルを開いて、
して vi でリプレースしてもヨイでつし、 sed で削除してもヨイでしょう。
sed '/^Requested Block:/d' badblock >> tmp2.txt sed '/^Error Block:/d' tmp2.txt >> tmp3.txt |
ここまでくると、同じ badblock number が 1 行に 2 つ書かれて
いるファイルが出来ているハヅでつ。
最後は cut か tr で重複部分を削除しませう。
で、最終的に badblock のみがファイルに書かれていればおっけ。
command-file を作る準備はこれでおしまい。
作り方はカンタン。
format コマンドをインタラクティヴ・モードで使用しているとき
のコマンドをファイルに直接書いていきまつ。
ftp で autopirot させるための .netrc に似た感じになりまつ。
今回は、 disk の repair が目的なので、 command-file の中身 はこうなりまつ。
repair ← command xxxxxxxxxxxxxxxxx ← badblock number repair xxxxxxxxxxxxxxxxx repair xxxxxxxxxxxxxxxxx repair xxxxxxxxxxxxxxxxx repair xxxxxxxxxxxxxxxxx repair xxxxxxxxxxxxxxxxx repair xxxxxxxxxxxxxxxxx repair xxxxxxxxxxxxxxxxx |
でつ。
command-file の書き方の注意は、インタラクティヴ・モードで
表示される、 y とか n とかの確認要求の応答を記述しちゃイケマセン。
コマンドのみでつ。
command-file の記述はこれでおしまい。
あとは、 format コマンドを起動するだけ。
インタラクティヴ・モードでは必要なかったオプションが
若干必要になりまつ。
起動方法の一例は・・・
# format -d c1t8d0 -f command-file |
でつ。
記述内容にミスがなければ、これでイッキにやってくれますよ。
dmesg や /var/log/messages でも Bad Block Number は特定できまつが、
format の analyze でも特定できまつ。
dmesg や /var/log/messages に載った Bad Block はアクセスした際に
発生したエラーを記録したに過ぎないので、これらで Bad Block を特定
しても、まだ Bad Block が残っている可能性がありまつ。
なので、いっそのコト、disk を全てチェックしてみゃぅ。
チェックする disk でつが、 予め umount しておいてくらさい。
んで、 format の起動から disk の選択、menu の表示までは今ま
でと同じなので snip。
format> analyze analyze> setup |
次に解析パラメータの入力を要求されまつ。
Analyze entire disk [yes]? n Enter starting block number [0, 0/0/0]: 0←開始 Block Number Enter ending block number [2052287, 2035/13/71]: 2052287←終了 Block Number Loop continuously [no]? y Repair defective blocks [yes]? n Stop after first error [no]? n Use random bit patterns [no]? n Enter number of blocks per transfer [126, 0/1/54]: 1 Verify media after formatting [yes]? y Enable extended messages [no]? n Restore defect list [yes]? y Create defect label [yes]? y |