A. サーバ構成
我が家では、NetBSD使っていて、RAIDFrameというソフトウエアRAIDです。Referenceは 「Chapter 15. NetBSD RAIDframe」
ハード的には、ThinkPad T23 に、120G のディスク(2.5" Seagate ST910821A)を2個。1台目側がwd0、2台目(Ultrabay にDVD-ROM抜いて、突っ込んである)がwd1に見えてます。これを、80Gと40Gのパーティションに分け、それぞれをraid0, raid1 というRAIDデバイスに設定してある。本当は160Gにしたかったんだけれど、BIOS的にダメでした。
これらのディスクは、fdisk パーティション的には、一つのNetBSDパーティションに見えていて、
Disk: /dev/rwd0d
NetBSD disklabel disk geometry:
cylinders: 232581, heads: 16, sectors/track: 63 (1008 sectors/cylinder)
total sectors: 234441648
BIOS disk geometry:
cylinders: 1023, heads: 240, sectors/track: 63 (15120 sectors/cylinder)
total sectors: 234441648
Partition table:
0: NetBSD (sysid 169)
start 63, size 234441585 (114473 MB, Cyls 0-15505/96/1), Active
1:
2:
3:
Bootselector disabled.
さらに、NetBSD の disklabel 的に、RAIDパーティションが二つ
# /dev/rwd0d: type: ESDI disk: ST9120821A label: fictitious flags: bytes/sector: 512 sectors/track: 63 tracks/cylinder: 16 sectors/cylinder: 1008 cylinders: 232581 total sectors: 234441648 rpm: 3600 interleave: 1 trackskew: 0 cylinderskew: 0 headswitch: 0 # microseconds track-to-track seek: 0 # microseconds drivedata: 0 16 partitions: # size offset fstype [fsize bsize cpg/sgs] b: 2097648 2097838 swap # (Cyl. 2081*- 4162*) c: 234441585 63 unused 0 0 # (Cyl. 0*- 232580) d: 234441648 0 unused 0 0 # (Cyl. 0 - 232580) e: 156301425 63 RAID # (Cyl. 0*- 155060) f: 78140160 156301488 RAID # (Cyl. 155061 - 232580) disklabel: partitions b and e overlap
e と f パーティションそれぞれで、raid0 / raid1 を組んであります。e がブートパーティション、raid0a というデバイスに見えることになります。
raid0は、
disklabel: Invalid signature in mbr record 0 # /dev/rraid0a: type: RAID disk: raid label: fictitious flags: bytes/sector: 512 sectors/track: 128 tracks/cylinder: 8 sectors/cylinder: 1024 cylinders: 152638 total sectors: 156301312 rpm: 3600 interleave: 1 trackskew: 0 cylinderskew: 0 headswitch: 0 # microseconds track-to-track seek: 0 # microseconds drivedata: 0 16 partitions: # size offset fstype [fsize bsize cpg/sgs] a: 2097648 0 4.2BSD 1024 8192 45608 # (Cyl. 0 - 2048*) b: 2097648 2097711 swap # (Cyl. 2048*- 4097*) c: 156301312 0 unused 0 0 # (Cyl. 0 - 152637) d: 156301312 0 unused 0 0 # (Cyl. 0 - 152637) e: 147909888 4195359 4.2BSD 1024 8192 46664 # (Cyl. 4097*- 148540*) f: 4196065 152105247 4.2BSD 1024 8192 46624 # (Cyl. 148540*- 152637)
raid1は、
disklabel: Invalid signature in mbr record 0 # /dev/rraid1a: type: RAID disk: raid label: fictitious flags: bytes/sector: 512 sectors/track: 128 tracks/cylinder: 8 sectors/cylinder: 1024 cylinders: 76308 total sectors: 78140032 rpm: 3600 interleave: 1 trackskew: 0 cylinderskew: 0 headswitch: 0 # microseconds track-to-track seek: 0 # microseconds drivedata: 0 4 partitions: # size offset fstype [fsize bsize cpg/sgs] a: 78140032 0 4.2BSD 0 0 0 # (Cyl. 0 - 76308*) c: 78140032 0 4.2BSD 2048 16384 28840 # (Cyl. 0 - 76308*) d: 78140032 0 unused 0 0 # (Cyl. 0 - 76308*) disklabel: partitions a and c overlap
「Invalid signature in mbr record 0」と「partitions a and c overlap」は、この場合問題ないので、気にしない。
B. 壊れているとこうなる
今回壊れたのは、wd1(ドライブベイ側)。試しに再起動したら、wd0が完全に死んでいて、BIOSから見えなかったらしく、自動的にwd1 から起動してました。
というわけで、新しい同型のドライブを1台調達し、動いている方、つまり、ドライブベイ側のドライブを内蔵に移した上で、ドライブベイ側に新しいドライブを入れました。これは、ハード分かってる人にお願いしました。ラップトップだから家族に持って行ってもらって対応できるのがイイところ。
立ち上げると、dmesg 的にはこういう状態。
wd0 at atabus0 drive 0:wd0: drive supports 16-sector PIO transfers, LBA48 addressing wd0: 111 GB, 232581 cyl, 16 head, 63 sec, 512 bytes/sect x 234441648 sectors wd0: 32-bit data port wd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 5 (Ultra/100) wd0(piixide0:0:0): using PIO mode 4, Ultra-DMA mode 5 (Ultra/100) (using DMA) wd1 at atabus1 drive 0: wd1: drive supports 16-sector PIO transfers, LBA48 addressing wd1: 111 GB, 232581 cyl, 16 head, 63 sec, 512 bytes/sect x 234441648 sectors wd1: 32-bit data port wd1: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 5 (Ultra/100) wd1(piixide0:1:0): using PIO mode 4, Ultra-DMA mode 5 (Ultra/100) (using DMA) raid0: RAID Level 1 raid0: Components: component0[**FAILED**] /dev/wd0e raid0: Total Sectors: 156301312 (76319 MB) raid1: RAID Level 1 raid1: Components: component0[**FAILED**] /dev/wd0f raid1: Total Sectors: 78140032 (38154 MB) (中略) raid0: Error re-writing parity! raid1: Error re-writing parity!
raidctl 的には、こういう感じになる。
pooh % sudo /sbin/raidctl -s raid0
Components:
component0: failed
/dev/wd0e: optimal
No spares.
component0 status is: failed. Skipping label.
Component label for /dev/wd0e:
Row: 0, Column: 1, Num Rows: 1, Num Columns: 2
Version: 2, Serial Number: 2004001, Mod Counter: 2383
Clean: No, Status: 0
sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
Queue size: 100, blocksize: 512, numBlocks: 156301312
RAID Level: 1
Autoconfig: Yes
Root partition: Yes
Last configured as: raid0
Parity status: DIRTY
Reconstruction is 100% complete.
Parity Re-write is 100% complete.
Copyback is 100% complete.
pooh 13% sudo /sbin/raidctl -s raid1
Components:
component0: failed
/dev/wd0f: optimal
No spares.
component0 status is: failed. Skipping label.
Component label for /dev/wd0f:
Row: 0, Column: 1, Num Rows: 1, Num Columns: 2
Version: 2, Serial Number: 2006001, Mod Counter: 301
Clean: No, Status: 0
sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
Queue size: 100, blocksize: 512, numBlocks: 78140032
RAID Level: 1
Autoconfig: Yes
Root partition: No
Last configured as: raid1
Parity status: DIRTY
Reconstruction is 100% complete.
Parity Re-write is 100% complete.
Copyback is 100% complete.
ポイントは、component0 といって見えていた(元のwd0)が消えて、wd1 としてconfigされていたものが wd0 として見えている状態(component1といってもいい)だといっているわけです。
C. 復旧手順
手順は、今回は、全く同じドライブを買ってきたので、以下のようになります。
- wd0 から wd1 へ、ラベルをコピーする(パーティションも)
- wd1 へ、ブートブロックをインストールする(しないと、入れ替えてもブートできない)
- component0 が wd1 になったことを教えるて、RAID再構築
- リブートと確認
1) ラベルのコピー
まず、sciriptしとく(失敗したときに、postmotemするための習慣)
pooh 8# mkdir /root/raidwork.2006-08 pooh 9# cd /root/raidwork.2006-08 pooh 10# script script.raidwork.2006-0830..txt Script started, output file is raidwork.2006-0830.txt
wd0 のラベルをよんでみる
pooh 1# /sbin/disklabel -r wd0 >disklabel.wd0 disklabel: partitions b and e overlap pooh 2# cat disklabel.wd0 /root/raidwork.2006-08 # /dev/rwd0d: type: ESDI disk: ST9120821A label: fictitious flags: bytes/sector: 512 sectors/track: 63 tracks/cylinder: 16 sectors/cylinder: 1008 cylinders: 232581 total sectors: 234441648 rpm: 3600 interleave: 1 trackskew: 0 cylinderskew: 0 headswitch: 0 # microseconds track-to-track seek: 0 # microseconds drivedata: 0 16 partitions: # size offset fstype [fsize bsize cpg/sgs] b: 2097648 2097838 swap # (Cyl. 2081*- 4162*) c: 234441585 63 unused 0 0 # (Cyl. 0*- 232580) d: 234441648 0 unused 0 0 # (Cyl. 0 - 232580) e: 156301425 63 RAID # (Cyl. 0*- 155060) f: 78140160 156301488 RAID # (Cyl. 155061 - 232580)
ここで、「disklabel: partitions b and e overlap」と出ているのは、crash dump の dump deviceの都合で、わざわざそうしてあるので、正常。
wd1 のラベルを一応読んでみる。
pooh 3# /sbin/disklabel -r wd1 disklabel: Invalid signature in mbr record 0 disklabel: no disklabel
ということで、空なので、wd1 で間違いないので、fdiskでパーティション作成。全てのディスクをNetBSD用に割り当て、boot selector なし、パーティションはアクティブにしておく(しないと、うごくけど、壊れたときにブートしない)。
pooh 4# /sbin/fdisk -0ua /dev/rwd1d fdisk: primary partition table invalid, no magic in sector 0 Disk: /dev/rwd1d NetBSD disklabel disk geometry: cylinders: 232581, heads: 16, sectors/track: 63 (1008 sectors/cylinder) total sectors: 234441648 BIOS disk geometry: cylinders: 1023, heads: 240, sectors/track: 63 (15120 sectors/cylinder) total sectors: 234441648 Do you want to change our idea of what BIOS thinks? [n] Partition 0:The data for partition 0 is: sysid: [0..255 default: 169] start: [0..15505cyl default: 63, 0cyl, 0MB] size: [0..15505cyl default: 234441585, 15505cyl, 114473MB] bootmenu: [] Do you want to change the active partition? [n] y Choosing 4 will make no partition active. active partition: [0..4 default: 0] 0 Are you happy with this choice? [n] y We haven't written the MBR back to disk yet. This is your last chance. Partition table: 0: NetBSD (sysid 169) start 63, size 234441585 (114473 MB, Cyls 0-15505/96/1), Active 1: 2: 3: Bootselector disabled. Should we write new partition table? [n] y
続いて、wd0から読んだラベルを書いちゃう。
pooh 5# /sbin/disklabel -R -r wd1 disklabel.wd0 disklabel: partitions b and e overlap
これでOKなんだけれど、念のために、読み出して比較。
pooh 6# /sbin/disklabel -r wd0 >disklabel.wd0.now disklabel: partitions b and e overlap pooh 7# /sbin/disklabel -r wd1 >disklabel.wd1.now disklabel: partitions b and e overlap pooh 8# diff disklabel.wd0.now disklabel.wd1.now 1c1 < # /dev/rwd0d: --- > # /dev/rwd1d: pooh 9# /sbin/fdisk /dev/rwd0 >fdisk.rwd0 pooh 10# /sbin/fdisk /dev/rwd1 >fdisk.rwd1 pooh 11# diff fdisk.rwd0 fdisk.rwd1 1c1 < Disk: /dev/rwd0d --- > Disk: /dev/rwd1d
ということで、ドライブ名以外に、差がないので正常。
2) wd1 にブートブロックのインストール
これを忘れると痛い。
pooh 12# /usr/sbin/installboot -o timeout=30 -v /dev/rwd1e /usr/mdec/bootxx_ffsv1rwd1e は、boot すべき RAIDパーティションが入っているデバイス。i386の場合は、ブロックオフセット63の奴が正しい「はず」。これ、ブートして確認できないので、この手順に従う人は、自分の責任で確認してください。 なんにせよ、reconstructする前にinstallbootしてれば、何も壊さないから大丈夫。あとでやる場合は、更に注意すべき。
3) RAID再構築
できあがった新しい RAIDパーティションを、RAIDセットに加え、RAIDセット再構築開始。RAIDセット二つあるので、まず、raid0にwd1eを追加して、ステータス確認
pooh 13# raidctl -v -a /dev/wd1e raid0
pooh 14# raidctl -s raid0
Components:
component0: failed
/dev/wd0e: optimal
Spares:
/dev/wd1e: spare
component0 status is: failed. Skipping label.
Component label for /dev/wd0e:
Row: 0, Column: 1, Num Rows: 1, Num Columns: 2
Version: 2, Serial Number: 2004001, Mod Counter: 2383
Clean: No, Status: 0
sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
Queue size: 100, blocksize: 512, numBlocks: 156301312
RAID Level: 1
Autoconfig: Yes
Root partition: Yes
Last configured as: raid0
/dev/wd1e status is: spare. Skipping label.
Parity status: DIRTY
Reconstruction is 100% complete.
Parity Re-write is 100% complete.
Copyback is 100% complete.
この状態で、wd1e がスペアとしてシステムに認識された。ということで、component0 の代わりに、wd1e を使うように指示する
pooh 15# raidctl -F component0 raid0
pooh 16# raidctl -s raid0
Components:
component0: reconstructing
/dev/wd0e: optimal
Spares:
/dev/wd1e: used_spare
component0 status is: reconstructing. Skipping label.
Component label for /dev/wd0e:
Row: 0, Column: 1, Num Rows: 1, Num Columns: 2
Version: 2, Serial Number: 2004001, Mod Counter: 2384
Clean: No, Status: 0
sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
Queue size: 100, blocksize: 512, numBlocks: 156301312
RAID Level: 1
Autoconfig: Yes
Root partition: Yes
Last configured as: raid0
Component label for /dev/wd1e:
Row: 0, Column: 0, Num Rows: 0, Num Columns: 0
Version: 0, Serial Number: 0, Mod Counter: 0
Clean: No, Status: 0
sectPerSU: 0, SUsPerPU: 0, SUsPerRU: 0
Queue size: 0, blocksize: 0, numBlocks: 0
RAID Level:
Autoconfig: No
Root partition: No
Last configured as: raid0
Parity status: DIRTY
Reconstruction is 0% complete.
Parity Re-write is 100% complete.
Copyback is 100% complete.
wd1e が used_spare になって、component0 が reconstructing になっている。wd1e のcomponent labelは、終わるまでは正しくない。ステータスを見てみる。(下記は^Cで止めた)
pooh 17# raidctl -S raid0 Reconstruction is 0% complete. Parity Re-write is 100% complete. Copyback is 100% complete. Reconstruction status: 0% | | ETA: 39:29 /^C
ということで、待つこと40分で、raid0 の再構築は終了(typescriptが長くなるので、raidctl -S は別のウィンドウでやる)。
最後に確認。
pooh 18# raidctl -s raid0
Components:
component0: spared
/dev/wd0e: optimal
Spares:
/dev/wd1e: used_spare
component0 status is: spared. Skipping label.
Component label for /dev/wd0e:
Row: 0, Column: 1, Num Rows: 1, Num Columns: 2
Version: 2, Serial Number: 2004001, Mod Counter: 2385
Clean: No, Status: 0
sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
Queue size: 100, blocksize: 512, numBlocks: 156301312
RAID Level: 1
Autoconfig: Yes
Root partition: Yes
Last configured as: raid0
Component label for /dev/wd1e:
Row: 0, Column: 0, Num Rows: 1, Num Columns: 2
Version: 2, Serial Number: 2004001, Mod Counter: 2385
Clean: No, Status: 0
sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
Queue size: 100, blocksize: 512, numBlocks: 156301312
RAID Level: 1
Autoconfig: Yes
Root partition: Yes
Last configured as: raid0
Parity status: clean
Reconstruction is 100% complete.
Parity Re-write is 100% complete.
Copyback is 100% complete.
これで、raid0 は完成。
ディスク別なら、raid1 も平行でできるのだけれど、同じディスクに二つRAIDパーティション置いておいて、両方再構築すると、シークが多くなって、余計に(しかも沢山)時間かかるので、raid1 は、raid0 が終わってから作りました。
pooh 19# raidctl -v -a /dev/wd1f raid1
pooh 20# raidctl -s raid1 /root/raidwork.2006-08
Components:
component0: failed
/dev/wd0f: optimal
Spares:
/dev/wd1f: spare
component0 status is: failed. Skipping label.
Component label for /dev/wd0f:
Row: 0, Column: 1, Num Rows: 1, Num Columns: 2
Version: 2, Serial Number: 2006001, Mod Counter: 301
Clean: No, Status: 0
sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
Queue size: 100, blocksize: 512, numBlocks: 78140032
RAID Level: 1
Autoconfig: Yes
Root partition: No
Last configured as: raid1
/dev/wd1f status is: spare. Skipping label.
Parity status: DIRTY
Reconstruction is 100% complete.
Parity Re-write is 100% complete.
Copyback is 100% complete.
で、再構築。
pooh 21# raidctl -F component0 raid1
確認
pooh 22# raidctl -S raid1 Reconstruction is 0% complete. Parity Re-write is 100% complete. Copyback is 100% complete. Reconstruction status: 0% | | ETA: 19:17 /^C
20分後、構築が終わるとこうなる。
pooh 23# raidctl -s raid1
Components:
component0: spared
/dev/wd0f: optimal
Spares:
/dev/wd1f: used_spare
component0 status is: spared. Skipping label.
Component label for /dev/wd0f:
Row: 0, Column: 1, Num Rows: 1, Num Columns: 2
Version: 2, Serial Number: 2006001, Mod Counter: 303
Clean: No, Status: 0
sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
Queue size: 100, blocksize: 512, numBlocks: 78140032
RAID Level: 1
Autoconfig: Yes
Root partition: No
Last configured as: raid1
Component label for /dev/wd1f:
Row: 0, Column: 0, Num Rows: 1, Num Columns: 2
Version: 2, Serial Number: 2006001, Mod Counter: 303
Clean: No, Status: 0
sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
Queue size: 100, blocksize: 512, numBlocks: 78140032
RAID Level: 1
Autoconfig: Yes
Root partition: No
Last configured as: raid1
Parity status: clean
Reconstruction is 100% complete.
Parity Re-write is 100% complete.
Copyback is 100% complete.
これで作業終了。
4) 最終確認
ステータスを見ると、 Spare が used_spare になり、component0 が spared になってますが、これは、再起動すると、綺麗になおります。こんな感じ
pooh 1% sudo raidctl -s raid0
Password:
Components:
/dev/wd1e: optimal
/dev/wd0e: optimal
No spares.
Component label for /dev/wd1e:
Row: 0, Column: 0, Num Rows: 1, Num Columns: 2
Version: 2, Serial Number: 2004001, Mod Counter: 2391
Clean: No, Status: 0
sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
Queue size: 100, blocksize: 512, numBlocks: 156301312
RAID Level: 1
Autoconfig: Yes
Root partition: Yes
Last configured as: raid0
Component label for /dev/wd0e:
Row: 0, Column: 1, Num Rows: 1, Num Columns: 2
Version: 2, Serial Number: 2004001, Mod Counter: 2391
Clean: No, Status: 0
sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
Queue size: 100, blocksize: 512, numBlocks: 156301312
RAID Level: 1
Autoconfig: Yes
Root partition: Yes
Last configured as: raid0
Parity status: clean
Reconstruction is 100% complete.
Parity Re-write is 100% complete.
Copyback is 100% complete.
pooh 2% sudo raidctl -s raid1
Components:
/dev/wd1f: optimal
/dev/wd0f: optimal
No spares.
Component label for /dev/wd1f:
Row: 0, Column: 0, Num Rows: 1, Num Columns: 2
Version: 2, Serial Number: 2006001, Mod Counter: 309
Clean: No, Status: 0
sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
Queue size: 100, blocksize: 512, numBlocks: 78140032
RAID Level: 1
Autoconfig: Yes
Root partition: No
Last configured as: raid1
Component label for /dev/wd0f:
Row: 0, Column: 1, Num Rows: 1, Num Columns: 2
Version: 2, Serial Number: 2006001, Mod Counter: 309
Clean: No, Status: 0
sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
Queue size: 100, blocksize: 512, numBlocks: 78140032
RAID Level: 1
Autoconfig: Yes
Root partition: No
Last configured as: raid1
Parity status: clean
Reconstruction is 100% complete.
Parity Re-write is 100% complete.
Copyback is 100% complete.
最後に、ブート時のdmesgは、こんな感じになっている
wd0 at atabus0 drive 0:wd0: drive supports 16-sector PIO transfers, LBA48 addressing wd0: 111 GB, 232581 cyl, 16 head, 63 sec, 512 bytes/sect x 234441648 sectors wd0: 32-bit data port wd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 5 (Ultra/100) wd0(piixide0:0:0): using PIO mode 4, Ultra-DMA mode 5 (Ultra/100) (using DMA) wd1 at atabus1 drive 0: wd1: drive supports 16-sector PIO transfers, LBA48 addressing wd1: 111 GB, 232581 cyl, 16 head, 63 sec, 512 bytes/sect x 234441648 sectors wd1: 32-bit data port wd1: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 5 (Ultra/100) wd1(piixide0:1:0): using PIO mode 4, Ultra-DMA mode 5 (Ultra/100) (using DMA) raid0: RAID Level 1 raid0: Components: /dev/wd1e /dev/wd0e raid0: Total Sectors: 156301312 (76319 MB) raid1: RAID Level 1 raid1: Components: /dev/wd1f /dev/wd0f raid1: Total Sectors: 78140032 (38154 MB) boot device: raid0 root on raid0a dumps on raid0b root file system type: ffs
0番目のドライブ(Row 0 Colum 0) が、新しくつけた wd1e なので、RAID的に順番が入れ替わって見えているのがちょっとだけ気持ち悪いんですが、まぁ、こんなもんかと。
色々確認しながらですが、再構築時間いれて1時間半ぐらいで終了しました。