LINUX_SOFT_RAID
需要安裝的套件: yum -y install mkinitrd mdadm
1. 看RAID 的狀況
1.1. 看RAID狀況的指令
cat proc/mdstat
出現的訊息如下:
#-------------------------------------------------------------------------------------
Personalities : [raid1]
md0 : active raid1 sdb1[1] sda1[0]
104320 blocks [2/2] [UU] <<<<----------以RAID1 來說這個是兩個硬碟都正常的
md3 : active raid1 sdb2[1]
943722240 blocks [2/1] [_U] <<<<----------以RAID1 來說有一個硬碟不良需要修復了
md2 : active raid1 sda3[2](F) sdb3[1]
10482304 blocks [2/1] [_U]
md1 : active raid1 sdb5[1] sda5[0]
4192832 blocks [2/2] [UU]
md4 : active raid1 sda6[2](F) sdb6[1]
18257728 blocks [2/1] [_U]
#-------------------------------------------------------------------------------------
1.2. 看個別的分割表的RAID狀況
mdadm --detail /dev/md0
出現的訊息如下:
#-------------------------------------------------------------------------------------
/dev/md0:
Version : 0.90
Creation Time : Tue Jul 20 13:16:42 2010
Raid Level : raid1
Array Size : 104320 (101.89 MiB 106.82 MB)
Used Dev Size : 104320 (101.89 MiB 106.82 MB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 0
Persistence : Superblock is persistent
Update Time : Sun Dec 5 10:33:36 2010
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
UUID : dfdd470a:02724ec7:9083ee64:e5f1e1fb
Events : 0.30
Number Major Minor RaidDevice State
0
8
1
0 active sync /dev/sda1
1
8
17
1 active sync /dev/sdb1
#-------------------------------------------------------------------------------------
2. 加入新的硬碟到RAID 內
2.1. mdadm --manage /dev/md0 --add /dev/hda1
3. 移除RAID 硬碟
3.1. mdadm --manage /dev/md4 --remove /dev/sda6
會出現如下的訊息
mdadm: hot removed /dev/sda6
代表已經移除了
4.將第一顆硬碟的磁碟分割表複製給第二顆硬碟,讓兩個分割表相同
4.1. sfdisk -d /dev/sda | sfdisk /dev/sdb
4.2. 可以用 fdisk -l 來查看分割狀況
4.3. 將分割表改成支援SOFT WARE RAID
fdisk /dev/sdb
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): fd
Changed system type of partition 2 to fd (Linux raid autodetect)
Command (m for help):
w
4.4. 清除 RAID superblock 方法
mdadm --zero-superblock /dev/sdb1