Installing CentOS 5 with RAID-1 以磁碟陣列一來安裝 CentOS 5
參考 CentOS 5.5 設定 Software Raid-1 備援系統 (記得應該是 CentOS 5.5 以上可以支援此功能):
Installation > Disk: Create Custom Layout > Next
Begins setting "/boot" mount point on RAID-1
Click on "RAID" button >Create a Software RAID Partition > OK
Select sda (de-select sdb) > size 200MB > Fixed size > OK
Create a Software RAID Partition > OK
Select sdb (de-select sda) > size 200MB > Fixed size > OK
Create a RAID device (default /dev/md0)
mount point (choose /boot) > filetype ext3 > RAID device md0 > RAID members (choose both sdb and sdb) > OK
Begins setting "/swap" mount point on RAID-1
Click on "RAID" button >Create a Software RAID Partition > OK
Select sda (de-select sdb) > size 4096MB > Fixed size > OK
Create a Software RAID Partition > OK
Select sdb (de-select sda) > size 4096MB > Fixed size > OK
Create a RAID device (default /dev/md1)
filetype swap > RAID device md1 > RAID members (choose both sdb and sdb) > OK
Begins setting "/" mount point on RAID-1
Click on "RAID" button >Create a Software RAID Partition > OK
Select sda (de-select sdb) > fill to maximum allowable size > OK
Create a Software RAID Partition > OK
Select sdb (de-select sda) > fill to maximum allowable size > OK
Create a RAID device (default /dev/md2)
mount point (choose "/") > filetype ext3 > RAID device md2 > RAID members (choose both sdb and sdb) > OK
install grub on md0 > other boot -- tick on md2
dealing with the remaining installation steps > installation completed
看 RAID 狀態:
boot > command line > cat /proc/mdstat
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>
df -h
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):
sfdisk -d /dev/sda | sfdisk /dev/sdb (分割表複製--從 sda 到 sdb 的意思) 或者:
sudo sfdisk -d /dev/sda | sudo sfdisk --force /dev/sdb (分割表複製--從 sda 到 sdb 的意思)
cat /proc/mdstat (再次確認 sdb 的分割狀況,若與安裝時有相同的磁區安排,就照以下指令重建)
mdadm /dev/md0 -a /dev/sdb1 (重建 md0)
mdadm /dev/md1 -a /dev/sdb2 (重建 md1)
mdadm /dev/md2 -a /dev/sdb3 (重建 md2)
watch cat /proc/mdstat (觀看進度)
或者用重建指令: mdadm --manage --run /dev/md0 | mdadm --manage --run /dev/md1 | mdadm --manage --run /dev/md2
BELOW QUOTED FROM: http://en.gentoo-wiki.com/wiki/RAID/Software
To rebuild a RAID 1:
Power down the system
Replace the failed disk
Power up the system once again
Create identical partitions on the new disk - i.e copy the partition scheme from the drive that is still online.
Remove the old partition from the array and add the new partition back
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!
參考: