这Megacli是操作磁盘Raid的常用软件,日常用的大多是dell家的机器,都是这软件,记录一下。
#!/bin/sh #/opt/MegaRAID/MegaCli/MegaCli64 -PDList -a0 /opt/MegaRAID/MegaCli/MegaCli64 -PDList -a0 | grep -A1 "Enclosure Device" # clear foreign disk #/opt/MegaRAID/MegaCli/MegaCli64 -cfgforeign -scan -a0 #/opt/MegaRAID/MegaCli/MegaCli64 -cfgforeign -clear -a0 # clear Firmware state #/opt/MegaRAID/MegaCli/MegaCli64 -PDList -a0 |grep 'Firmware state' #/opt/MegaRAID/MegaCli/MegaCli64 -PDMakeGood -Physdrv "[32:3]" -a0 # clear Firmware JBOD mode, first turn into unconfig mode, then MakeGood #/opt/MegaRAID/MegaCli/MegaCli64 -PDList -a0 |grep 'Firmware state' #/opt/MegaRAID/MegaCli/MegaCli64 -PDMakeGood -Physdrv [32:3] -force -a0 #/opt/MegaRAID/MegaCli/MegaCli64 AdpGetProp EnableJBOD -aALL #/opt/MegaRAID/MegaCli/MegaCli64 -AdpSetProp -EnableJBOD -1 -a0 #/opt/MegaRAID/MegaCli/MegaCli64 -PDMakeJBOD -PhysDrv[252:0] -a0 # create Raid0 #/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r0[252:3] -a0 # Get old Cache, ex: Virtual Drive(Target ID 02) #/opt/MegaRAID/MegaCli/MegaCli64 -GetPreservedCacheList -a0 # Clear cache, ex: Virtual Drive(Target ID 02) #/opt/MegaRAID/MegaCli/MegaCli64 -DiscardPreservedCache -L2 -a0 # create Raid1 #/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r1[252:4,252:5] -a0 # create Raid5 #/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r5[252:2,252:3,252:4,252:5] -a0 # create Raid10 #/opt/MegaRAID/MegaCli/MegaCli64 -CfgSpanAdd -r10 -Array0[32:4,32:5] -Array1[32:6,32:7] -a0 #delete raid #/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdDel -L0 -a0 #Virtual Drive: 0 (Target Id: 0) # check Raid #/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL #RAID 1 #RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0 #RAID 5 #RAID Level : Primary-5, Secondary-0, RAID Level Qualifier-3 # check Raid disks #/opt/MegaRAID/MegaCli/MegaCli64 -LdPdInfo -aAll | egrep "^Adapter|^Number of Virtual|^Virtual Drive:|^Name|^Enclosure Device ID:|^Slot Number:" # GPT part #parted -s /dev/sde mklabel gpt mkpart primary 0% 100% # check disk rebuild progress #/opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -ShowProg -physdrv[32:1] -aALL #Rebuild Progress on Device at Enclosure 32, Slot 1 Completed 7% in 3 Minutes. # Force rebuild #/opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -Start -physdrv[32:1] -a0 # OR #/opt/MegaRAID/MegaCli/MegaCli64 -pdlocate -start -physdrv[32:1] -a0 #Start rebuild, first clean the foreign configuration and then make the device hot spare (only if the above command failed) #/opt/MegaRAID/MegaCli/MegaCli64 -CfgForeign -Clear -aALL #set global hostspare #/opt/MegaRAID/MegaCli/MegaCli64 -PDHSP -Set -PhysDrv [32:1] -a0 #If you need to unset/remove a global hotspare: #/opt/MegaRAID/MegaCli/MegaCli64 -PDHSP -Rmv -PhysDrv [32:1] -aN #downgrade raid6 --> raid5 ,and more space now can be used # -L0 virtual disk 0 # /opt/MegaRAID/MegaCli/MegaCli64 -LDRecon -Start -r5 -L0 -a0 # echo 1 > /sys/block/sda/device/rescan #Add disk to a raid5 #/opt/MegaRAID/MegaCli/MegaCli64 -LDRecon -Start -r5 -Add -PhysDrv[32:3] -L0 -a #Configure WriteThrough or WriteBack #/opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp -WT -Immediate -Lall -aAll #/opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp -WB -Immediate -Lall -aAll #/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL |grep "Inquiry Data:" #Inquiry Data: SEAGATE ST600MP0005 VS08S7M04B0C #Inquiry Data: SEAGATE ST600MP0005 VS08S7M04AFD #Inquiry Data: SEAGATE ST600MP0005 VS08S7M04JAY #Inquiry Data: SEAGATE ST600MP0005 VS08S7M04AAG #/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL | grep "Drive Temperature" #Drive Temperature :36C (96.80 F) #Drive Temperature :35C (95.00 F)