LSI / Broadcom MegaRAID Storcli

# install storcli (MegaCli)
# https://www.broadcom.com/products/storage/raid-controllers/megaraid-sas-9361-4i#downloads
 
apt install -y unzip
wget https://docs.broadcom.com/docs-and-downloads/raid-controllers/raid-controllers-common-files/007.0606.0000.0000_Unified_StorCLI.zip -O /tmp/StorCLI.zip
unzip /tmp/StorCLI.zip -d /tmp/
unzip /tmp/MR_SAS_Unified_StorCLI_*.zip -d /tmp
unzip /tmp/versionChangeSet/univ_viva_cli_rel/Unified_storcli_all_os.zip -d /tmp/
dpkg -i /tmp/Unified_storcli_all_os/Ubuntu/storcli_*_all.deb
ln -s /opt/MegaRAID/storcli/storcli64 /usr/local/sbin/storcli
 
or
 
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/
/tmp/versionChangeSet/univ_viva_cli_rel/storcli_All_OS/Ubuntu/opt/MegaRAID/storcli/storcli
ln -s /tmp/versionChangeSet/univ_viva_cli_rel/storcli_All_OS/Ubuntu/opt/MegaRAID/storcli/storcli /sbin/MegaCli
 
cp /scripts/MegaCli/MegaCli64  /usr/sbin/
ln -s /usr/sbin/MegaCli64 /usr/sbin/MegaCli
cp /scripts/MegaCli/lib/$(uname -m)/libsysfs.so.2.0.2  /usr/lib64/
 
# list
http://fibrevillage.com/storage/709-storcli-drive-command-examples
http://fibrevillage.com/storage/710-storcli-virtual-drive-command-examples
storcli /c0 /eall /sall show
storcli64 /c0/vall del cachecade
storcli64 /c0/v1 del force
 
storcli64 /c0/v0 show
storcli /cx/vx set cachedbadbbu=<on|off>
 
 
# del
storcli64 /c0/v1 del
 
 
# flash bios
storcli -adpfwflash -f /scripts/firmware/lsi_imr_fw.rom -aALL
 
# force fw flash
storcli -adpfwflash -f imr_fw.rom -NoVerChk -aAll
 
# reset to factory default
storcli -adpfacdefset -aALL 
 
# controller info
storcli -AdpAllinfo -aALL 
storcli -PDGetNum -a0       # nubmer of discs
storcli -PDInfo -PhysDrv [64:0] -aALL
storcli -PDMakeJBOD -PhysDrv[64:4]
 
# clear controller config to defaults
storcli -CfgClr -aALL 
 
# delete all
storcli -CfgLdDel -LALL -aALL
 
# create raid
storcli -CfgLdAdd -r5 [64:0, 64:1, 64:2, 64:3] -a0
storcli -CfgLdAdd -r0 [64:4,64:5,64:6,64:7] -a0
 
# get free devices
storcli -PDList -a0 | grep -e '^Enclosure Device ID:' -e '^Slot Number:'
 
# get raid info
storcli -LDInfo -Lall -aALL
storcli -PDMakeGood -PhysDrv[64:4] -force -aALL > /dev/null
storcli -PDMakeGood -PhysDrv[64:5] -force -aALL > /dev/null
storcli -PDMakeGood -PhysDrv[64:6] -force -aALL > /dev/null
storcli -PDMakeGood -PhysDrv[64:7] -force -aALL > /dev/null
storcli -PDMakeJBOD -PhysDrv[64:4,64:5,64:6,64:7]  -a0
storcli -CfgLdAdd -r0 [64:4,64:5,64:6,64:7] -a0
storcli -AdpEventLog -GetEvents -f logfile -aALL  # Dump all events from the adapters event log to a file named logfile
storcli -PDList -aAll # Dump information about all Phsyical Disks
storcli -LDInfo -LAll -aAll       # Dump information about all Logical Disks on all adapters
storcli -LdPdInfo -aAll    # Dump information of all logical and physical disks on all known adapters
 
storcli /cAll /eAll /sAll show | egrep "[0-9]+:[0-9]+"
 
# get configuration as JSON output
storcli64 /cAll show J
storcli /c0/v0 show J | jq -r '.Controllers[0]."Response Data"."Virtual Drives"[0].State'
 
storcli -AdpSetProp -EnableJBOD 1 -aALL
storcli -CfgDsply -aAll
 
# create JBOD
storcli -CfgEachDskRaid0 WB RA Direct CachedBadBBU -a0
 
# adapter diagnostic
storcli -AdpDiag -a0
 
Controller information
storcli -AdpAllInfo -aALL
storcli -CfgDsply -aALL
storcli -AdpEventLog -GetEvents -f events.log -aALL && cat events.log
 
Enclosure information
storcli -EncInfo -aALL 
 
Virtual drive information
storcli -LDInfo -Lall -aALL 
 
Physical drive information
storcli -PDList -aALL
storcli -PDInfo -PhysDrv [E:S] -aALL 
 
Battery backup information
storcli -AdpBbuCmd -aALL 
 
Controller management
 
Silence active alarm
storcli -AdpSetProp AlarmSilence -aALL 
 
Disable alarm
storcli -AdpSetProp AlarmDsbl -aALL 
MegaCli64 -AdpSetProp <AlarmEnbl | AlarmDsbl | AlarmSilence> -aN
 
 
Enable alarm
storcli -AdpSetProp AlarmEnbl -aALL 
 
Physical drive management
 
Set state to offline
storcli -PDOffline -PhysDrv [E:S] -aN 
 
Set state to online
storcli -PDOnline -PhysDrv [E:S] -aN 
 
Mark as missing
storcli -PDMarkMissing -PhysDrv [E:S] -aN 
 
Prepare for removal
storcli -PdPrpRmv -PhysDrv [E:S] -aN 
 
Replace missing drive
storcli -PdReplaceMissing -PhysDrv [E:S] -ArrayN -rowN -aN 
 
Rebuild drive
storcli -PDRbld -Start -PhysDrv [E:S] -aN
storcli -PDRbld -Stop -PhysDrv [E:S] -aN
storcli -PDRbld -ShowProg -PhysDrv [E:S] -aN
 
Clear drive
storcli -PDClear -Start -PhysDrv [E:S] -aN
storcli -PDClear -Stop -PhysDrv [E:S] -aN
storcli -PDClear -ShowProg -PhysDrv [E:S] -aN
 
 
storcli -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
storcli -PDOffline -PhysDrv [E:S] -aN 
 
Mark the drive as missing
storcli -PDMarkMissing -PhysDrv [E:S] -aN 
 
Prepare drive for removal
storcli -PDPrpRmv -PhysDrv [E:S] -aN 
 
If you’re using hot spares then the replaced drive should become your new hot spare drive:
storcli -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
storcli -PdReplaceMissing -PhysDrv [E:S] -ArrayN -rowN -aN
storcli -PDRbld -Start -PhysDrv [E:S] -aN
storcli -CfgLdAdd -r0 [0:1, 0:1] -a0
storcli -LDInfo -Lall -aALL
# View all controleler informations
storcli -AdpAllInfo -aAll
 
storcli -LDSetProp CachedBadBBU -LALL -aALL
Delete all devices
storcli -CfgLdDel -LALL -aALL
 
# crate RAID1
storcli -CfgLdAdd -r1 [252:0,252:1] -a0
 
# create RAID5
storcli -CfgLdAdd -r5 [64:0,64:1,64:2,64:3] -a0
 
# create RAID10
storcli -CfgSpanAdd -r10 -Array0[64:0,64:1] -Array1[64:2,64:3] -a0
storcli -CfgSpanAdd -r10 -Array0[252:0,252:1] -Array1[252:2,252:3] -Array2[252:4,252:5] -a0
 
 
# create RAID10
storcli -AdpSetProp -EnableJBOD 1
 
# Enable disks cache
storcli -LDSetProp EnDskCache -LAll -aAll
 
# Force flash
storcli -adpfwflash  -f ./12.12.0-0111.rom -NoVerChk -a0
 
# load controller defauts
storcli -adpfacdefset -aALL
 
# delete / clear foreign discs
storcli -CfgForeign -Clear -a0 
 
# delete logical volume and enable jbod
#storcli /c0/v0 delete force
storcli /cAll/vAll delete force
storcli -adpfacdefset -aALL
storcli -AdpSetProp -EnableJBOD 1 -aALL
 
# get statistics
ln -s /usr/local/sbin/storcli /usr/local/sbin/megacli
wget http://nova.polymtl.ca/~coyote/dist/megaclisas-status/megaclisas-status
chmod +x megaclisas-status
./megaclisas-status

boot error

storcli /cAll set stoponerror=off
storcli /cAll set bios=on
storcli /cAll set headlessafemode=on
storcli /cAll set headlesscontinueonerror=on

Events

storcli /cx delete events
storcli /cAll show events

Links
https://docs.broadcom.com/docs-and-downloads/raid-controllers/raid-controllers-common-files/StorCLI_RefMan_revf.pdf
https://www.broadcom.com/support/knowledgebase/1211161499760/lsi-command-line-interface-cross-reference-megacli-vs-twcli-vs-s
https://wiki.hetzner.de/index.php/LSI_RAID_Controller
ftp://ftp.supermicro.com/driver/SAS/LSI/ - Firmware download
http://hwraid.le-vert.net/wiki/LSIMegaRAIDSAS
http://wiki.hetzner.de/index.php/LSI_RAID_Controller
http://www.awerner.homeip.net/doku.php?id=it-artikel:lsi-megaraid-cli-utility-fuer-sas-raid-controller#downloads
http://darkspot.de/schnipsel/allgemein/45-raid-megaraid.html
http://tools.rapidsoft.de/perc/perc-cheat-sheet.html