MegaCLI / MegaRAID / LSI / RAID Controller CLI stuff

How to use the MegaCLI Utility with your RAID Controller

This article provides information on how to use the MegaCLI utility with your RAID controller on your PowerEdge or Supermicro server in Linux.


Getting the Information

Controller Information

$ -AdpAllInfo -aALL
$ -CfgDsply -aALL
$ -AdpEventLog -GetEvents -f events.log -aALL && cat events.log

Enclosure Information

$ -EncInfo -aALL

Virtual Drive Information

$ -LDInfo -Lall -aALL


Controller Management

Silence Active Alarm

$ -AdpSetProp AlarmSilence -aALL

Disable alarm

$ -AdpSetProp AlarmDsbl -aALL

Enable Alarm

$ -AdpSetProp AlarmEnbl -aALL


Virtual Drive Management

Create RAID 0:

$ -cfgldadd -r0 [E:S,E:S] -a0

Create RAID 1:

$ -cfgldadd -r1 [E:S,E:S] -a0

Create RAID 5:

$ -CfgLdAdd -r5 [E:S,E:S,…] -a0

Create Raid 6 with 8 drives, 300GB as the OS Drive and the rest will be for Data:

$ -CfgLdAdd r6 [E:S,E:S,E:S,E:S,E:S,E:S,E:S,E:S] -sz300GB -a0
$ -CfgLdAdd r6 [E:S,E:S,E:S,E:S,E:S,E:S,E:S,E:S] -a0

Create Raid 10:

$-CfgSpanAdd r10 Array0[E:S,E:S,…] Array1[E:S,E:S,…] -a0

Create Raid 10 with 16 Drives 50GB as the OS drive and Rest will be for Data:

-CfgSpanAdd r10 Array0[24:0,24:1] Array1[24:2,24:3] Array2[24:4,24:5] Array3[24:6,24:7] Array4[24:8,24:9] Array5[24:10,24:11] Array6[24:12,24:13] Array7[24:14,24:15] -sz51200 -a0 
-CfgSpanAdd r10 Array0[24:0,24:1] Array1[24:2,24:3] Array2[24:4,24:5] Array3[24:6,24:7] Array4[24:8,24:9] Array5[24:10,24:11] Array6[24:12,24:13] Array7[24:14,24:15] -a0 

Physical Drive Management

Set State to Offline:

$ -PDOffline -PhysDrv [E:S] -aN

Set State to Online:

$ -PDOnline -PhysDrv [E:S] -aN

Mark as Missing:

$ -PDMarkMissing -PhysDrv [E:S] -aN

Prepare for Removal:

$ -PdPrpRmv -PhysDrv [E:S] -aN

Replace Missing Drive:

$ -PdReplaceMissing -PhysDrv [E:S] -ArrayN -rowN -aN

To Get the Numbers Use:

$ -Pdgetmissing -aN

Show Rebuild Progress:

$ -PDRbld -ShowProg -PhysDrv[E:S] -aN

Delete All Configs:

$ -CfgLdDel -Lall -aAll

Clear/Delete Foreign Configuration:

$ -CfgForeign -Clear -aALl


Note that ‘E’ stands for Enclosure device and ‘S’ for Slot Number.

NOTE 1: Arrays greater than 2 TB in size must be partitioned using GPT. A normal BIOS cannot boot off of large GPT partitions, so we must first create a small array for the system to boot off of.

The following will create a 50GB 8-disk RAID10 array, and then a 2nd 8-disk RAID10 array using the remaining space on the disks:

-CfgSpanAdd r10 Array0[E:S,E:S] Array1[E:S,E:S] Array2[E:S,E:S] Array3[E:S,E:S] -sz51200 -a0
-CfgSpanAdd r10 Array0[E:S,E:S] Array1[E:S,E:S] Array2[E:S,E:S] Array3[E:S,E:S] -a0

NOTE 2: When you setup a new box, install a new RAID card, or setup a new RAID array, always run the following commands:

-AdpBIOS -BE -aALL
-AdpSetProp -BatWarnDsbl 1 -aALL
-LDSetProp WT -LALL -aALL


Note 3: These commands are only valid when you are in the LSI command line. If you are in bash, you will have to append the command ‘megacli’ in front of each arguments and flags.