|
RAIDをいじる。ソフトウェアRAIDだと、低価格で高度なRAIDが構築できて楽しい。 RAIDとして起動しない場合に強制的に起動させる † RAID構成としての最低限のディスク(4台のRAID5のうち3台あるなど)がある場合でも、ディスクの壊れ方などのタイミングによっては、RAIDとして起動しなくなることがある。 # mdadm --detail /dev/md2
/dev/md2:
Version : 00.90.03
Creation Time : Sun Nov 21 20:38:58 2004
Raid Level : raid5
Device Size : 312568576 (298.09 GiB 320.07 GB)
Raid Devices : 4
Total Devices : 4
Preferred Minor : 2
Persistence : Superblock is persistent
Update Time : Sun Jun 17 14:35:29 2007
State : active, degraded, Not Started
Active Devices : 3
Working Devices : 4
Failed Devices : 0
Spare Devices : 1
Layout : left-asymmetric
Chunk Size : 128K
UUID : xxxxxxxx:xxxxxxxx:xxxxxxxx:xxxxxxxx
Events : 0.8396843
Number Major Minor RaidDevice State
0 22 65 0 active sync /dev/hdd1
1 8 33 1 active sync /dev/sdc1
2 3 1 2 active sync /dev/hda1
3 0 0 3 removed
4 8 49 - spare /dev/sdd1
ステータスが「active, degraded, Not Started」となっている。 md: md2 stopped. md: bind<sdc1> md: bind<hda1> md: bind<sdd1> md: bind<hdd1> md: md2: raid array is not clean -- starting background reconstruction raid5: device hdd1 operational as raid disk 0 raid5: device hda1 operational as raid disk 2 raid5: device sdc1 operational as raid disk 1 raid5: cannot start dirty degraded array for md2 RAID5 conf printout: --- rd:4 wd:3 fd:1 disk 0, o:1, dev:hdd1 disk 1, o:1, dev:sdc1 disk 2, o:1, dev:hda1 raid5: failed to run raid set md2 md: pers->run() failed ... この状態だと、RAIDを起動しようとしてもエラーとなる。 # mdadm --run /dev/md2 mdadm: failed to run array /dev/md2: Input/output error 強制的に起動させるには、md_modのパラメータのstart_dirty_degradedを1に設定すればよいらしい。 # echo 1 > /sys/module/md_mod/parameters/start_dirty_degraded 設定後、再度RAIDを起動すると、今度は正常に起動した。 # mdadm --detail /dev/md2
/dev/md2:
Version : 00.90.03
Creation Time : Sun Nov 21 20:38:58 2004
Raid Level : raid5
Array Size : 937705728 (894.27 GiB 960.21 GB)
Device Size : 312568576 (298.09 GiB 320.07 GB)
Raid Devices : 4
Total Devices : 4
Preferred Minor : 2
Persistence : Superblock is persistent
Update Time : Sun Jun 17 14:35:29 2007
State : clean, degraded, recovering
Active Devices : 3
Working Devices : 4
Failed Devices : 0
Spare Devices : 1
Layout : left-asymmetric
Chunk Size : 128K
Rebuild Status : 1% complete
UUID : xxxxxxxx:xxxxxxxx:xxxxxxxx:xxxxxxxx
Events : 0.8396843
Number Major Minor RaidDevice State
0 22 65 0 active sync /dev/hdd1
1 8 33 1 active sync /dev/sdc1
2 3 1 2 active sync /dev/hda1
4 8 49 3 spare rebuilding /dev/sdd1
ステータスが「clean, degraded, recovering」となっている。 # mdadm --detail /dev/md2
/dev/md2:
Version : 00.90.03
Creation Time : Sun Nov 21 20:38:58 2004
Raid Level : raid5
Array Size : 937705728 (894.27 GiB 960.21 GB)
Device Size : 312568576 (298.09 GiB 320.07 GB)
Raid Devices : 4
Total Devices : 4
Preferred Minor : 2
Persistence : Superblock is persistent
Update Time : Thu Jun 21 01:05:30 2007
State : clean, resyncing
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0
Layout : left-asymmetric
Chunk Size : 128K
Rebuild Status : 11% complete
UUID : xxxxxxxx:xxxxxxxx:xxxxxxxx:xxxxxxxx
Events : 0.8396845
Number Major Minor RaidDevice State
0 22 65 0 active sync /dev/hdd1
1 8 33 1 active sync /dev/sdc1
2 3 1 2 active sync /dev/hda1
3 8 49 3 active sync /dev/sdd1
ステータスが「clean, resyncing」となっている。 RAID1で片肺でのブート † RAID1でブートディスクを作っても、通常は片方しかGRUBが入らないようだ。このため、もう片方にもGRUBをインストールする。 # grub grub> device (hd0) /dev/hdb # (hd0) を /dev/hdb とする grub> root (hd0,0) # /boot があるパーティション(/dev/hdb1)指定 grub> setup (hd0) # (hd0) の MBR に GRUB をインストール ディスク交換後の復旧 †HDDを交換後、アレイを再構築するには以下のコマンドを実行する。 mdadm /dev/md2 --add /dev/sdb1 /proc/mdstat でリビルド状況がわかるはずだ。 アレイサイズ変更 †小さくする †ext3 †ファイルシステムのサイズを減らし、続いてアレイのサイズを減らす。 # umount /mnt/hoge # e2fsck -f /dev/md0 (*1) # resize2fs /dev/md0 100000 (*2) # mdadm /dev/md0 --grow --size=400000 (*3) # mount /mnt/hoge (*1) サイズ変更前にやっておかないと、resize2fsに怒られる場合がある。 大きくする †ext3 †アレイのサイズを増やし、ファイルシステムのサイズを増やす。 # umount /mnt/hoge # mdadm /dev/md0 --grow --size=600000 (*1) # e2fsck -f /dev/md0 (*2) # resize2fs /dev/md0 (*3) # mount /mnt/hoge (*1) サイズに"max"を指定すると、指定できる最大値が設定される。 jfs †オンラインでリサイズできるのでアンマウントの必要がない。 # mdadm /dev/md0 --grow --size=max # mount -o remount,resize /mnt/hoge (*1) (*1) サイズの指定はできないようだ。 xfs †サイズを増やすのは簡単。xfs_growfsではサイズの指定も出来るが、ここではデフォルトの最大を割り当てた。 # mdadm /dev/md0 --grow --size=max # xfs_growfs /mnt/hoge 320Gから500Gへの拡張は、ほとんど一瞬で出来た。 スーパーブロックの初期化 †アレイに新品ではないHDDを使用するときは、スーパーブロックを初期化する必要がある。 # mdadm --zero-superblock /dev/hda1 auto-read-onlyとなる場合の対処 †RAID0のswapとして使用していた領域をRAID1に変更すると、raidの状態が以下のようになった。 md1 : active (auto-read-only) raid1 sda2[0] sdb2[1]
979840 blocks [2/2] [UU]
ググるといくつかヒットするが、いまいち解決方法が見つからない。 とりあえず、以下のコマンドを実行して書き込み可能にしておく。 # mdadm --readwrite /dev/md1 参考 †http://lists.debian.or.jp/debian-users/200608/msg00173.html |