Installing CentOS 5 with RAID-1 以磁碟陣列一來安裝 CentOS 5

參考 CentOS 5.5 設定 Software Raid-1 備援系統 (記得應該是 CentOS 5.5 以上可以支援此功能):

看 RAID 狀態:

Personalities : [raid1]

md0 : active raid1 sdb1[1] sda1[0]

      200704 blocks [2/2] [UU]

md1 : active raid1 sdb2[1] sda2[0]

      4192896 blocks [2/2] [UU]

md2 : active raid1 sdb3[1] sda3[0]

      620735424 blocks [2/2] [UU]

unused devices: <none>

Filesystem            Size  Used Avail Use% Mounted on

/dev/md2              574G  4.4G  540G   1% /

/dev/md0              190M   18M  163M  10% /boot

tmpfs                1005M     0 1005M   0% /dev/shm

重建(假設壞 sdb):

To rebuild a RAID 1:

You can copy a partition map from one disk to another with sfdisk. Additionally, since the target drive is not in use we can rewrite partition map with fdisk to force the partition map to be re-read by the kernel:

#sfdisk -d dev/sdX | sfdisk /dev/sdY

#fdisk /dev/sdY

Command (m for help): w

To remove the failed partition and add the new partition:

#mdadm /dev/mdX -r /dev/sdYZ -a /dev/sdYZ

Note: do this for each of your partitions. i.e. md0 md1 md2 etc.

Watch the automatic reconstruction run with:

#watch -n1 cat /proc/mdstat

If one of the partitions is a boot partition, don't forget to re-run grub on that partition so that grub boots from the new disk, not from the disk you copied the partition from using sfdisk. This is important if you ever have to replace that disk!

參考: