LSI / Broadcom MegaRAID Storcli

# install storcli (MegaCli)

wget -qO /tmp/
unzip /tmp/ -d /tmp/
unzip /tmp/versionChangeSet/univ_viva_cli_rel/ -d /tmp/versionChangeSet/univ_viva_cli_rel/
dpkg -x /tmp/versionChangeSet/univ_viva_cli_rel/storcli_All_OS/Ubuntu/storcli_*_all.deb /tmp/versionChangeSet/univ_viva_cli_rel/storcli_All_OS/Ubuntu/
ln -s /tmp/versionChangeSet/univ_viva_cli_rel/storcli_All_OS/Ubuntu/opt/MegaRAID/storcli/storcli64 /sbin/MegaCli

cp /scripts/MegaCli/MegaCli64 /usr/sbin/
ln -s /usr/sbin/MegaCli64 /usr/sbin/MegaCli
cp /scripts/MegaCli/lib/$(uname -m)/ /usr/lib64/

# flash bios
MegaCli -adpfwflash -f /scripts/firmware/lsi_imr_fw.rom -aALL

# force fw flash
MegaCli -adpfwflash -f imr_fw.rom -NoVerChk -aAll

# reset to factory default
MegaCli -adpfacdefset -aALL

# controller info
MegaCli -AdpAllinfo -aALL
MegaCli -PDGetNum -a0 # nubmer of discs
MegaCli -PDInfo -PhysDrv [64:0] -aALL
MegaCli -PDMakeJBOD -PhysDrv[64:4]

# clear controller config to defaults
MegaCli -CfgClr -aALL

# delete all
MegaCli -CfgLdDel -LALL -aALL

# create raid
MegaCli -CfgLdAdd -r5 [64:0, 64:1, 64:2, 64:3] -a0
MegaCli -CfgLdAdd -r0 [64:4,64:5,64:6,64:7] -a0

# get free devices
MegaCli -PDList -a0 | grep -e '^Enclosure Device ID:' -e '^Slot Number:'

# get raid info
MegaCli -LDInfo -Lall -aALL
MegaCli -PDMakeGood -PhysDrv[64:4] -force -aALL > /dev/null
MegaCli -PDMakeGood -PhysDrv[64:5] -force -aALL > /dev/null
MegaCli -PDMakeGood -PhysDrv[64:6] -force -aALL > /dev/null
MegaCli -PDMakeGood -PhysDrv[64:7] -force -aALL > /dev/null
MegaCli -PDMakeJBOD -PhysDrv[64:4,64:5,64:6,64:7] -a0
MegaCli -CfgLdAdd -r0 [64:4,64:5,64:6,64:7] -a0
MegaCli -AdpEventLog -GetEvents -f logfile -aALL # Dump all events from the adapters event log to a file named logfile
MegaCli -PDList -aAll # Dump information about all Phsyical Disks
MegaCli -LDInfo -LAll -aAll # Dump information about all Logical Disks on all adapters
MegaCli -LdPdInfo -aAll # Dump information of all logical and physical disks on all known adapters
MegaCli -AdpSetProp -EnableJBOD 1 -aALL
MegaCli -CfgDsply -aAll

# create JBOD
/opt/MegaRAID/storcli/storcli64 -CfgEachDskRaid0 -aALL

# adapter diagnostic
MegaCli -AdpDiag -a0

Controller information
MegaCli -AdpAllInfo -aALL
MegaCli -CfgDsply -aALL
MegaCli -AdpEventLog -GetEvents -f events.log -aALL && cat events.log

Enclosure information
MegaCli -EncInfo -aALL

Virtual drive information
MegaCli -LDInfo -Lall -aALL

Physical drive information
MegaCli -PDList -aALL
MegaCli -PDInfo -PhysDrv [E:S] -aALL

Battery backup information
MegaCli -AdpBbuCmd -aALL

Controller management

Silence active alarm
MegaCli -AdpSetProp AlarmSilence -aALL

Disable alarm
MegaCli -AdpSetProp AlarmDsbl -aALL
MegaCli64 -AdpSetProp -aN

Enable alarm
MegaCli -AdpSetProp AlarmEnbl -aALL

Physical drive management

Set state to offline
MegaCli -PDOffline -PhysDrv [E:S] -aN

Set state to online
MegaCli -PDOnline -PhysDrv [E:S] -aN

Mark as missing
MegaCli -PDMarkMissing -PhysDrv [E:S] -aN

Prepare for removal
MegaCli -PdPrpRmv -PhysDrv [E:S] -aN

Replace missing drive
MegaCli -PdReplaceMissing -PhysDrv [E:S] -ArrayN -rowN -aN

Rebuild drive
MegaCli -PDRbld -Start -PhysDrv [E:S] -aN
MegaCli -PDRbld -Stop -PhysDrv [E:S] -aN
MegaCli -PDRbld -ShowProg -PhysDrv [E:S] -aN

Clear drive
MegaCli -PDClear -Start -PhysDrv [E:S] -aN
MegaCli -PDClear -Stop -PhysDrv [E:S] -aN
MegaCli -PDClear -ShowProg -PhysDrv [E:S] -aN

MegaCli -PDMakeGood -PhysDrv[E:S] -aN
This changes drive in state Unconfigured-Bad to Unconfigured-Good.

Set the drive offline, if it is not already offline due to an error
MegaCli -PDOffline -PhysDrv [E:S] -aN

Mark the drive as missing
MegaCli -PDMarkMissing -PhysDrv [E:S] -aN

Prepare drive for removal
MegaCli -PDPrpRmv -PhysDrv [E:S] -aN

If you’re using hot spares then the replaced drive should become your new hot spare drive:
MegaCli -PDHSP -Set -PhysDrv [E:S] -aN

In case you’re not working with hot spares, you must re-add the new drive to your RAID virtual drive and start the rebuilding
MegaCli -PdReplaceMissing -PhysDrv [E:S] -ArrayN -rowN -aN
MegaCli -PDRbld -Start -PhysDrv [E:S] -aN
MegaCli -CfgLdAdd -r0 [0:1, 0:1] -a0
MegaCli -LDInfo -Lall -aALL
# View all controleler informations
MegaCli -AdpAllInfo -aAll

MegaCli -LDSetProp CachedBadBBU -LALL -aALL
Delete all devices
MegaCli -CfgLdDel -LALL -aALL

# crate RAID1
MegaCli -CfgLdAdd -r1 [252:0,252:1] -a0

# create RAID5
MegaCli -CfgLdAdd -r5 [64:0,64:1,64:2,64:3] -a0

# create RAID10
MegaCli -CfgSpanAdd -r10 -Array0[64:0,64:1] -Array1[64:2,64:3] -a0
MegaCli -CfgSpanAdd -r10 -Array0[252:0,252:1] -Array1[252:2,252:3] -Array2[252:4,252:5] -a0

# create RAID10
MegaCli -AdpSetProp -EnableJBOD 1

# Enable disks cache
MegaCli -LDSetProp EnDskCache -LAll -aAll

# Force flash
MegaCli -adpfwflash -f ./12.12.0-0111.rom -NoVerChk -a0

# load controller defauts
MegaCli -adpfacdefset -aALL

# delete / clear foreign discs
storcli64 -CfgForeign -Clear -a0

Links - Firmware download