参考元サイト
How to install NetBSD on RAID1 using RAIDframe
The NetBSD Guide - Chapter 16. NetBSD RAIDframe
Parallel Data Laboratory RAIDframe
必要なもの
NetBSDは5.0以降を使用します。空のハードディスクを2つ使用しRAID-1(ミラーリング)上にNetBSDをインストールします。
はじめ
NetBSDインストールCDから起動し、インストール時のメッセージ(English)を選択、キーボードタイプ(日本語)を選択した後のインストール・システムメニューから始めます。
ユーティリティ・メニューを選択し、シェルを実行します。
e:Utility menu
そして、
a: Run /bin/sh
Raidframeの確認
NetBSDにはソフトウェアRAIDを行うためRAIDframeというものがカーネルに組み込まれています。dmesgを見ると確認できます。
> dmesg
...
Kernelized RAIDframe activated
...
ハードディスクの確認
ハードディスクを確認します。wd1も同様に確認します。
> fdisk /dev/rwd0d
fdisk: primary partition table invalid, no magic in sector 0
Disk: /dev/rwd0d
NetBSD disklabel disk geometry:
cylinders: 17753, heads: 15, sectors/track: 63 (945 sectors/cylinder)
total sectors: 16777216
BIOS disk geometry:
cylinders: 962, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
total sectors: 16777216
Partition table:
0: <UNUSED>
1: <UNUSED>
2: <UNUSED>
3: <UNUSED>
Bootselector disabled.
No active partition.
パテーションの削除
もし、パテーションが存在している場合には以下のように、パテーション情報がある部分にゼロを書き込みパテーションを削除します。wd1も同様に行います。
> dd if=/dev/zero of=/dev/rwd0d bs=8k count=1
パテーションの作成
fdiskでwd0にパテーションを作成します。wd1も同様に行います。
> fdisk -0ua /dev/rwd0d
Disk: /dev/rwd0d
NetBSD disklabel disk geometry:
cylinders: 17753, heads: 15, sectors/track: 63 (945 sectors/cylinder)
total sectors: 16777216
BIOS disk geometry:
cylinders: 962, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
total sectors: 16777216
Do you want to change our idea of what BIOS thinks? [n]
Partition 0:
NetBSD (sysid 169)
start 63, size 16777153 (8192 MB, Cyls 0-1044/85/1), Active
PBR is not bootable: All bytes are identical (0x00)
The data for partition 0 is:
NetBSD (sysid 169)
start 63, size 16777153 (8192 MB, Cyls 0-1044/85/1), Active
PBR is not bootable: All bytes are identical (0x00)
sysid: [0..255 default: 169]
start: [0..1044dcyl default: 63, 0dcyl, 0MB]
size: [0..1044dcyl default: 16777153, 1044dcyl, 8192MB]
bootmenu: []
Do you want to change the active partition? [n] y
Choosing 4 will make no partition active.
active partition: [0..4 default: 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 16777153 (8192 MB, Cyls 0-1044/85/1), Active
PBR is not bootable: All bytes are identical (0x00)
1: <UNUSED>
2: <UNUSED>
3: <UNUSED>
Bootselector disabled.
First active partition: 0
Should we write new partition table? [n] y
ファイルシステム・タイプの変更
disklabelでファイルシステム・タイプを 4.2BSDからRAID に変更します。wd1も同様に行います。
NetBSDのRAIDframeは、ファイルシステム・タイプがRAIDであるハードディスクをRAIDデバイスとして使用します。
> disklabel -i -I wd0
partition> P
5 partitions:
# size offset fstype [fsize bsize cpg/sgs]
c: 16777153 63 unused 0 0 # (Cyl. 0*- 17753*)
d: 16777216 0 unused 0 0 # (Cyl. 0 - 17753*)
e: 16777153 63 4.2BSD 0 0 0 # (Cyl. 0*- 17753*)
partition> e
Filesystem type [?] [4.2BSD]: RAID
Start offset ('x' to start after partition 'x') [0.0666667c, 63s, 0.0307617M]:
Partition size ('$' for all remaining) [17753.6c, 16777153s, 8191.97M]:
e: 16777153 63 RAID # (Cyl. 0*- 17753*)
partition> W
Label disk [n]? y
Label written
partition> Q
RAID-1(ミラーリング)デバイスの構築
以上でハードディスクの下準備ができました。これからはRAIDを構築します。
RAID構築用の初期設定ファイルを作成します。
> cat > /tmp/raid0.conf << EOF
> START array
> 1 2 0
>
> START disks
> /dev/wd0e
> /dev/wd1e
>
> START layout
> 128 1 1 1
>
> START queue
> fifo 100
> EOF
RAID初期設定ファイルを使用しraid0というデバイス名でRAIDを構築します。
> raidctl -v -C /tmp/raid0.conf raid0
raid0: Component /dev/wd0e being configured at col: 0
Column: 0 Num Columns: 0
Version: 0 Serial Number: 0 Mod Counter: 0
Clean: No Status: 0
Number of columns do not match for: /dev/wd0e
/dev/wd0e is not clean!
raid0: Component /dev/wd1e being configured at col: 1
Column: 0 Num Columns: 0
Version: 0 Serial Number: 0 Mod Counter: 0
Clean: No Status: 0
Column out of alignment for: /dev/wd1e
Number of columns do not match for: /dev/wd1e
/dev/wd1e is not clean!
raid0: There were fatal errors
raid0: Fatal errors being ignored.
raid0: RAID Level 1
raid0: Components: /dev/wd0e /dev/wd1e
raid0: Total Sectors: 16777088 (8191 MB)
RAIDデバイスraid0にシリアル・ナンバーを書き込みます。例では日付を使いました。
> raidctl -v -I 20111119 raid0
RAIDデバイスraid0を初期化します。
> raidctl -v -i raid0
Initiating re-write of parity
Parity Re-write status:
99% |***************************************| ETA: 00:01 |
RAIDデバイスraid0を自動構成にし、ルートパテーションの識別を設定します。
> raidctl -v -A root raid0
raid0: New autoconfig value is: 1
raid0: New rootpartition value is: 1
raid0: Autoconfigure: Yes
raid0: Root: Yes
RAIDデバイスの確認
RAIDデバイスraid0の状態を表示し確認します。
> raidctl -v -s raid0
Components:
/dev/wd0e: optimal
/dev/wd1e: optimal
No spares.
Component label for /dev/wd0e:
Row: 0, Column: 0, Num Rows: 1, Num Columns: 2
Version: 2, Serial Number: 20111119, Mod Counter: 9
Clean: No, Status: 0
sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
Queue size: 100, blocksize: 512, numBlocks: 16777088
RAID Level: 1
Autoconfig: Yes
Root partition: Yes
Last configured as: raid0
Component label for /dev/wd1e:
Row: 0, Column: 1, Num Rows: 1, Num Columns: 2
Version: 2, Serial Number: 20111119, Mod Counter: 9
Clean: No, Status: 0
sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
Queue size: 100, blocksize: 512, numBlocks: 16777088
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.
ブート設定
2つのハードディスクには、どちらかでも起動できるようにinstallbootを設定します。シリアルコンソールを使います。wd1にも同様に行います。
> installboot -v -o timeout=10,console=com0,speed=115200 /dev/rwd0e /usr/mdec/bootxx_ffsv1
File system: /dev/rwd0e
Primary bootstrap: /usr/mdec/bootxx_ffsv1
Ignoring PBR with invalid magic in sector 0 of `/dev/rwd0e'
Boot options: timeout 10, flags 0, speed 115200, ioaddr 0, console com0
終了!
以上の作業でRAIDを構築できました。exitとタイプし、インストーラーへ戻ってNetBSDをインストールします。
NetBSDのインストール途中、インストール先を聞かれる場面がありますが、そこでRAIDデバイスraid0を選択します。
それ以外のインストール作業は、普通に進めます。
インストール後のfstabです。当たり前ですが、ちゃんとRAIDデバイスが指定されています。
> cat /etc/fstab
# NetBSD /etc/fstab
# See /usr/share/examples/fstab/ for more examples.
/dev/raid0a / ffs rw 1 1
/dev/raid0b none swap sw,dp 0 0
kernfs /kern kernfs rw
ptyfs /dev/pts ptyfs rw
procfs /proc procfs rw
/dev/cd0a /cdrom cd9660 ro,noauto
その他
/etc/rc.confにswapoff=YESが必要です。おそらく/etc/default/rc.confに設定されているはずですので、改めて設定する必要はないです。
どちらもThe NetBSD Guide - Chapter 16. NetBSD RAIDframe の最後のあたりに書いてあります。
システムを再起動、電源遮断を行う場合には、reboot、poweroffコマンドは使用せず、shutdownコマンドを使用した方が良いようです。reboot、poweroffコマンドを使うと、RAIDデバイスのパリティ・ステータスが”DIRTY"になってしまいます。(終了時に、swap領域をunmountしないようです。/etc/rc.confのswapoff関連ですね。)
もちろん、自動でclean状態に回復しますが、ちょっと気持ち悪いのでshutdownを使用しましょう。
NetBSD5.0以前は、カーネルダンプがRAIDデバイス上に出力できないため、それに対応する作業が必要です。面倒なので5.0以降をつかいましょう。
個人的なこと
過去にRAID5を使ったサーバーで同時に2つのハードディスクが壊れた経験があります。RAID5では使用するディスクの数も増えるので故障の可能性も増えます。最近はディスクの容量が大きくなったのでRAID1(ミラーリング)がちょうど良いと思います。