利用 4 个磁盘进行 RAID10 自动创建

因业务需要, 添加了新的磁盘, 因此需要把磁盘重新整合为 RAID10


参考当前磁盘

[root@hh-yun-compute-131104 ~]#  megacli -PDList -aALL | grep 'Inquiry Data:'
Inquiry Data: HITACHI HUC109060CSS600 A440KWKR7GHX
Inquiry Data: HITACHI HUC109060CSS600 A440KWKN3LRX
Inquiry Data: SEAGATE ST600MM0006     B001S0M4JC64
Inquiry Data: SEAGATE ST600MM0006     B001S0M4HTAB

查询磁盘当前状态

[root@hh-yun-compute-131104 ~]# megacli -PDlist -aALL | grep "ID"  | uniq   <- 取 252
Enclosure Device ID: 252
[root@hh-yun-compute-131104 ~]# megacli -PDList -aALL |  grep -E "DISK\ GROUP|Slot\ Number|postion:|Firmware\ state:"  
Slot Number: 0
Drive's postion: DiskGroup: 0, Span: 0, Arm: 0
Firmware state: Online, Spun Up
Slot Number: 1
Drive's postion: DiskGroup: 0, Span: 0, Arm: 1
Firmware state: Online, Spun Up
Slot Number: 2
Firmware state: Unconfigured(good), Spun down   <- 新添加磁盘
Slot Number: 3
Firmware state: Unconfigured(good), Spun down   <- 新添加磁盘


重组raid 磁盘方法

#!/bin/bash
rpm -ivh --force --nodeps  http://10.199.129.21/vclound/tmp/megacli-8.04.07-2.x86_64.rpm
uiqnum=` megacli -PDlist -aALL | grep "ID"  | uniq | awk -F: '{print $2}' | awk '{print $1}'`
disknum=`megacli -PDList -aALL |  grep -E "DISK\ GROUP|Slot\ Number|postion:|Firmware\ state:" | grep Slot | awk  -F[:\ ] '{print $NF}'`
disktotal=`megacli -PDList -aALL |  grep -E "DISK\ GROUP|Slot\ Number|postion:|Firmware\ state:" | grep Slot | awk  -F[:\ ] '{print $NF}' | wc -l`
if [ $disktotal -eq 4 ]
then
  array=($disknum)
  megacli -CfgLdDel -L0 -force -a0
  megacli -CfgSpanAdd -r10 -Array0[$uiqnum:${array[0]},$uiqnum:${array[1]}] -Array1[$uiqnum:${array[2]},$uiqnum:${array[3]}] -a0
fi 




你可能感兴趣的:(linux,megacli)