Match: Format: Sort by:

MegaCLI / MegaRAID / LSI / RAID controller CLI stuff

This document is kept under RCS at ~invent/docs/private/megacli_raid_lsi.html. Useful information and software is at:

ls ~invent/COnotes/hw-raid-monitor/
aaccli  - adaptec raid stuff (not liked)
lsiutil - LSI RAID card that was in insula (not liked)
megacli - H700 RAID cards that we do like


mr_sas_sw_ug - megacli reference manual from LSI (PDF)

${megacli} conventions

Adapter parameter -aN

The parameter -aN (where N is a number starting with zero or the string ALL) specifies the PERC5/i adapter ID. If you have only one controller itī is safe to use ALL instead of a specific ID, but you are encouraged to use the ID fohing that makes changes to your RAID configuration.

Physical drive parameter -PhysDrv [E:S]

For commands that operate on one or more pysical drives, the -PhysDrv [E:S] parameter is used, where E is the enclosure device ID in which the drive resides and S the slot number (starting with zero). You can get the enclosure device ID using '${megacli} -EncInfo -aALL'. The E:S syntax is also used for specifying the physical drives when creating a new RAID ual drive.

${megacli} -EncInfo -aALL 
    Number of enclosures on adapter 0 -- 1

    Enclosure 0:
    Device ID                     : 32
    Number of Slots               : 14
    Number of Power Supplies      : 0
    Number of Fans                : 0
    Number of Temperature Sensors : 0
    Number of Alarms              : 0
    Number of SIM Modules         : 0
    Number of Physical Drives     : 14
    Status                        : Normal
    Position                      : Unavailable
    Connector Name                : Unavailable

Example for slot 2:
cabbage:/etc/cron.d $ ${megacli}PDInfo -PhysDrv [32:2] -aALL

Virtual drive parameter -Lx

The parameter -Lx is used for specifying the virtual drive (where x is a number starting with zero or the string all).

Gather information

The CLI in DAMTP is available at :


    * Controller information
      ${megacli} -AdpAllInfo -aALL
      ${megacli} -CfgDsply -aALL
      ${megacli} -AdpEventLog -GetEvents -f events.log -aALL && cat events.log
      cd /tmp; ${megacli} -AdpEventLog -GetEvents -f events.log -aALL && tail -n 30 events.log

    * Enclosure information
      ${megacli} -EncInfo -aALL

    * Virtual drive information
      ${megacli} -LDInfo -Lall -aALL
${megacli} -LDPDInfo -aALL | less
Not the easiest output to read. Lists Virtual Drives, and then (in a rather long
format) the physical drives (by slot number) in each virtual drive.

    * Physical drive information
      ${megacli} -PDList -aALL
      ${megacli} -PDInfo -PhysDrv [E:S] -aALL

    * Battery backup information
      ${megacli} -AdpBbuCmd -aALL

* Background initialisation (OnGoing Progresses)
${megacli} -LDInfo -LALL -aALL
  Background Initialization: Completed 21%, Taken 312 min.

* set the background initialisation rate (GBI) to 90% :
$megacli -AdpSetProp BgiRate 90 -aAll

Controller management


    * Silence active alarm
      ${megacli} -AdpSetProp AlarmSilence -aALL

    * Disable alarm
      ${megacli} -AdpSetProp AlarmDsbl -aALL

    * Enable alarm
      ${megacli} -AdpSetProp AlarmEnbl -aALL

Virtual drive management

    * Create RAID 0, 1, 5 drive
      ${megacli} -CfgLdAdd -r(0|1|5) [E:S, E:S, ...] -aN

    * Create RAID 10 drive
      ${megacli} -CfgSpanAdd -r10 -Array0[E:S,E:S] -Array1[E:S,E:S] -aN

    * Remove drive
      ${megacli} -CfgLdDel -Lx -aN

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
      to get the numbers use:
      ${megacli} -Pdgetmissing -a0
novadisk:/home/raid/supp/mr349 $ ${megacli} -Pdgetmissing -a0
    Adapter 0 - Missing Physical drives
    No.   Array   Row   Size Expected
    0     1       4     1907200 MB
novadisk:/home/raid/supp/mr349 $ ${megacli} -PdReplaceMissing -PhysDrv [32:4] -Array1 -row4 -a0
Adapter: 0: Missing PD at Array 1, Row 4 is replaced.

    * 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} -PDClear -Start -PhysDrv [32:4] -aALL
${megacli} -PDClear -ShowProg -PhysDrv [32:4] -aALL

    * Bad to good
      ${megacli} -PDMakeGood -PhysDrv[E:S] -aN
      Changes drive in state Unconfigured-Bad to Unconfigured-Good.

    * Show missing drives
      ${megacli} -Pdgetmissing -a0

Hot spare management

    * Set global hot spare
      ${megacli} -PDHSP -Set -PhysDrv [E:S] -aN

    * Remove hot spare
      ${megacli} -PDHSP -Rmv -PhysDrv [E:S] -aN

    * Set dedicated hot spare
      ${megacli} -PDHSP -Set -Dedicated -ArrayN,M,... -PhysDrv [E:S] -aN

Walkthrough: Change/replace a drive

 To enable autorebuild 
      ${megacli} -AdpAutoRbld -Enbl -a0

 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 (seems to not work on R510 H700 card, so just do the next step)
      ${megacli} -PDMarkMissing -PhysDrv [E:S] -aN

 Prepare drive for removal
      ${megacli} -PDPrpRmv -PhysDrv [E:S] -aN

 Change/replace the drive

 To watch the rebuild progress on drive 11 (counted 0 to 11) on controller 0 and enclosure 32
      ${megacli} -PDRbld -ShowProg -PhysDrv[32:11] -a0

 If you are using hot spares then the replaced drive should become your new hot spare drive
      ${megacli} -PDHSP -Set -PhysDrv [E:S] -aN

 In case you are not working with hot spares, you must re-add the new drive to your RAID virtual drive and start rebuilding
      ${megacli} -PdReplaceMissing -PhysDrv [E:S] -ArrayN -rowN -aN
      to get the numbers use:
      ${megacli} -Pdgetmissing -a0
      ${megacli} -PDRbld -Start -PhysDrv [E:S] -aN

Dump the log file, to send through to Dell.

Dell technical support like to sift through this file.

${megacli} -fwtermlog -dsply -aall > /tmp/ttylog.txt

Sniffing through the log, we saw this:
delice:~/tmp $ grep -n ErrLba ttylog.txt
1251:09/01/12 11:35:35: prCallback: Medium Error on pd=04, StartLba=e1e8c000, ErrLba=e1e8c767
1265:09/01/12 11:35:39: prCallback: Medium Error on pd=04, StartLba=e1e8c768, ErrLba=e1e8c768
1278:09/01/12 11:35:42: prCallback: Medium Error on pd=04, StartLba=e1e8c769, ErrLba=e1e8c76b
1291:09/01/12 11:35:45: prCallback: Medium Error on pd=04, StartLba=e1e8c76c, ErrLba=e1e8c76c
delice:~/tmp $

The ErrLba= indicates a hardware error on the specified block.  It seems
the raid controller attempted to read the data, and found it to be
corrupted.  But, it then wrote it back, and all is now okay again:

delice:~/tmp $ grep -n orrected ttylog.txt
1257:09/01/12 11:35:37: EVT#05429-09/01/12 11:35:37: 110=Corrected medium error during recovery on PD 04(e0x20/s4) at e1e8c767
1258:09/01/12 11:35:37: EVT#05430-09/01/12 11:35:37:  93=Patrol Read corrected medium error on PD 04(e0x20/s4) at e1e8c767
1271:09/01/12 11:35:40: EVT#05432-09/01/12 11:35:40: 110=Corrected medium error during recovery on PD 04(e0x20/s4) at e1e8c768
1272:09/01/12 11:35:40: EVT#05433-09/01/12 11:35:40:  93=Patrol Read corrected medium error on PD 04(e0x20/s4) at e1e8c768
1284:09/01/12 11:35:43: EVT#05435-09/01/12 11:35:43: 110=Corrected medium error during recovery on PD 04(e0x20/s4) at e1e8c76b
1285:09/01/12 11:35:43: EVT#05436-09/01/12 11:35:43:  93=Patrol Read corrected medium error on PD 04(e0x20/s4) at e1e8c76b
1297:09/01/12 11:35:46: EVT#05438-09/01/12 11:35:46: 110=Corrected medium error during recovery on PD 04(e0x20/s4) at e1e8c76c
1298:09/01/12 11:35:46: EVT#05439-09/01/12 11:35:46:  93=Patrol Read corrected medium error on PD 04(e0x20/s4) at e1e8c76c
delice:~/tmp $

I was told that if it sees many of these errors (many being a loose
definition which varies from disk to disk) the controller will raise a
predictive failure error.  Until then, we ignore it.

Another Cheat - Sheet of megacli commands

~]# MegaCLI -help
      MegaCLI SAS RAID Management Tool  Ver 1.01.39 Aug 01, 2007
    (c)Copyright 2007, LSI Logic Corporation, All Rights Reserved.
${megacli} -v 
${megacli} -help|-h|? 
${megacli} -adpCount 
${megacli} -AdpSetProp {CacheFlushInterval -val}|{ RebuildRate -val} 
    |{PatrolReadRate -val}|{BgiRate -val}|{CCRate -val} 
    |{ReconRate -val}|{SpinupDriveCount -val}|{SpinupDelay -val} 
    |{CoercionMode -val}|{ClusterEnable -val}|{PredFailPollInterval -val} 
    |{BatWarnDsbl -val} |{EccBucketSize -val} | {EccBucketLeakRate -val} 
    |{AbortCCOnError val} | AlarmEnbl | AlarmDsbl | AlarmSilence -aN|-a0,1,2|-aALL 
${megacli} -AdpGetProp CacheFlushInterval | RebuildRate | PatrolReadRate | BgiRate 
    | CCRate | ReconRate | SpinupDriveCount | SpinupDelay | CoercionMode
    | PredFailPollInterval | EccBucketSize | EccBucketLeakRate | EccBucketCount
    | ClusterEnable | BatWarnDsbl | AbortCCOnError | AlarmDsply -aN|-a0,1,2|-aALL 
${megacli} -AdpAllInfo -aN|-a0,1,2|-aALL  
${megacli} -AdpGetTime -aN|-a0,1,2|-aALL  
${megacli} -AdpSetTime yyyymmdd hh:mm:ss -aN   
${megacli} -AdpSetVerify -f fileName -aN|-a0,1,2|-aALL  
${megacli} -AdpBIOS -Enbl |-Dsbl | -SOE | -BE | -Dsply -aN|-a0,1,2|-aALL 
${megacli} -AdpBootDrive {-Set -Lx}|-Get -aN|-a0,1,2|-aALL 
${megacli} -AdpAutoRbld -Enbl|-Dsbl|-Dsply -aN|-a0,1,2|-aALL
${megacli} -AdpCacheFlush -aN|-a0,1,2|-aALL
${megacli} -AdpPR -Dsbl|EnblAuto|EnblMan|Start|Stop|Info|{SetDelay Val} 
${megacli} -AdpCcSched -Dsbl|-Info|{-ModeConc | -ModeSeq [-ExcludeLD -LN|-L0,1,2]
   [-SetStartTime yyyymmdd hh ] [-SetDelay val ] } -aN|-a0,1,2|-aALL
${megacli} -AdpCcSched -SetStartTime yyyymmdd hh -aN|-a0,1,2|-aALL
${megacli} -AdpCcSched -SetDelay val  -aN|-a0,1,2|-aALL
${megacli} -FwTermLog -BBUoff|BBUoffTemp|BBUon|BBUGet|Dsply|Clear -aN|-a0,1,2|-aALL
${megacli} -AdpShutDown -aN|-a0,1,2|-aALL
${megacli} -PDList -aN|-a0,1,2|-aALL 
${megacli} -PDGetNum -aN|-a0,1,2|-aALL 
${megacli} -pdInfo -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL  
${megacli} -PDOnline  -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL 
${megacli} -PDOffline -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL 
${megacli} -PDMakeGood -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL 
${megacli} -PDHSP {-Set [-Dedicated [-ArrayN|-Array0,1,2...]] [-EnclAffinity] [-nonRevertible]} 
         |-Rmv -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL 
${megacli} -PDRbld -Start|-Stop|-ShowProg |-ProgDsply 
        -PhysDrv [E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL  
${megacli} -PDClear -Start|-Stop|-ShowProg |-ProgDsply 
        -PhysDrv [E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL  
${megacli} -PdLocate {[-start] | -stop} -physdrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL 
${megacli} -PdMarkMissing -physdrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL 
${megacli} -PdGetMissing -aN|-a0,1,2|-aALL 
${megacli} -PdReplaceMissing -physdrv[E0:S0] -arrayA, -rowB -aN 
${megacli} -PdPrpRmv [-UnDo] -physdrv[E0:S0] -aN|-a0,1,2|-aALL  
${megacli} -EncInfo -aN|-a0,1,2|-aALL 
${megacli} -PhyInfo -phyM -aN|-a0,1,2|-aALL  
${megacli} -LDInfo -Lx|-L0,1,2|-Lall -aN|-a0,1,2|-aALL 
${megacli} -LDSetProp  {-Name LdNamestring} | -RW|RO|Blocked | WT|WB|RA|NORA|ADRA 
        | Cached|Direct | -EnDskCache|DisDskCache | CachedBadBBU|NoCachedBadBBU
        -Lx|-L0,1,2|-Lall -aN|-a0,1,2|-aALL 
${megacli} -LDGetProp  -Cache | -Access | -Name | -DskCache -Lx|-L0,1,2|-LALL  
${megacli} -LDInit {-Start [-full]}|-Abort|-ShowProg|-ProgDsply -Lx|-L0,1,2|-LALL -aN|-a0,1,2|-aALL 
${megacli} -LDCC -Start|-Abort|-ShowProg|-ProgDsply -Lx|-L0,1,2|-LALL -aN|-a0,1,2|-aALL 
${megacli} -LDBI -Enbl|-Dsbl|-getSetting|-Abort|-ShowProg|-ProgDsply -Lx|-L0,1,2|-LALL -aN|-a0,1,2|-aALL  
${megacli} -LDRecon {-Start -rX [{-Add | -Rmv} -Physdrv[E0:S0,...]]}|-ShowProg|-ProgDsply 
        -Lx -aN 
${megacli} -LdPdInfo -aN|-a0,1,2|-aALL 
${megacli} -LDGetNum -aN|-a0,1,2|-aALL 
${megacli} -CfgLdAdd -rX[E0:S0,E1:S1,...] [WT|WB] [NORA|RA|ADRA] [Direct|Cached]
        [CachedBadBBU|NoCachedBadBBU] [-szXXX [-szYYY ...]]
        [-strpszM] [-Hsp[E0:S0,...]] [-AfterLdX] -aN 
${megacli} -CfgEachDskRaid0 [WT|WB] [NORA|RA|ADRA] [Direct|Cached] 
        [CachedBadBBU|NoCachedBadBBU] [-strpszM] -aN|-a0,1,2|-aALL
${megacli} -CfgClr -aN|-a0,1,2|-aALL 
${megacli} -CfgDsply -aN|-a0,1,2|-aALL 
${megacli} -CfgLdDel -LX|-L0,2,5...|-LALL -aN|-a0,1,2|-aALL 
${megacli} -CfgFreeSpaceinfo -aN|-a0,1,2|-aALL 
${megacli} -CfgSpanAdd -r10 -Array0[E0:S0,E1:S1] -Array1[E0:S0,E1:S1] [-ArrayX[E0:S0,E1:S1] ...] 
        [WT|WB] [NORA|RA|ADRA] [Direct|Cached] [CachedBadBBU|NoCachedBadBBU]
        [-szXXX[-szYYY ...]][-strpszM][-AfterLdX] -aN
${megacli} -CfgSpanAdd -r50 -Array0[E0:S0,E1:S1,E2:S2,...] -Array1[E0:S0,E1:S1,E2:S2,...] 
        [-ArrayX[E0:S0,E1:S1,E2:S2,...] ...] [WT|WB] [NORA|RA|ADRA] [Direct|Cached] 
        [CachedBadBBU|NoCachedBadBBU][-szXXX[-szYYY ...]][-strpszM][-AfterLdX] -aN
${megacli} -CfgSave -f filename -aN   
${megacli} -CfgRestore -f filename -aN   
${megacli} -CfgForeign -Scan -aN|-a0,1,2|-aALL    
${megacli} -CfgForeign -Dsply [x] -aN|-a0,1,2|-aALL    
${megacli} -CfgForeign -Preview [x] -aN|-a0,1,2|-aALL    
${megacli} -CfgForeign -Import [x] -aN|-a0,1,2|-aALL    
${megacli} -CfgForeign -Clear [x] -aN|-a0,1,2|-aALL    
        x - index of foreign configurations. Optional. All by default. 
${megacli} -AdpEventLog -GetEventLogInfo -aN|-a0,1,2|-aALL 
${megacli} -AdpEventLog -GetEvents         -f  -aN|-a0,1,2|-aALL 
${megacli} -AdpEventLog -GetSinceShutdown  -f  -aN|-a0,1,2|-aALL 
${megacli} -AdpEventLog -GetSinceReboot    -f  -aN|-a0,1,2|-aALL 
${megacli} -AdpEventLog -IncludeDeleted    -f  -aN|-a0,1,2|-aALL 
${megacli} -AdpEventLog -GetLatest n -f  -aN|-a0,1,2|-aALL 
${megacli} -AdpEventLog -GetCCIncon -f  -LX|-L0,2,5...|-LALL -aN|-a0,1,2|-aALL 
${megacli} -AdpEventLog -Clear -aN|-a0,1,2|-aALL 
${megacli} -AdpBbuCmd -aN|-a0,1,2|-aALL  
${megacli} -AdpBbuCmd -GetBbuStatus -aN|-a0,1,2|-aALL  
${megacli} -AdpBbuCmd -GetBbuCapacityInfo -aN|-a0,1,2|-aALL  
${megacli} -AdpBbuCmd -GetBbuDesignInfo -aN|-a0,1,2|-aALL  
${megacli} -AdpBbuCmd -GetBbuProperties -aN|-a0,1,2|-aALL  
${megacli} -AdpBbuCmd -BbuLearn -aN|-a0,1,2|-aALL  
${megacli} -AdpBbuCmd -BbuMfgSleep -aN|-a0,1,2|-aALL  
${megacli} -AdpBbuCmd -BbuMfgSeal -aN|-a0,1,2|-aALL  
${megacli} -AdpBbuCmd -SetBbuProperties -f  -aN|-a0,1,2|-aALL 
${megacli} -AdpFacDefSet -aN 
${megacli} -AdpFwFlash -f filename [-NoSigChk] [-NoVerChk] -aN|-a0,1,2|-aALL  
${megacli} -AdpGetConnectorMode -ConnectorN|-Connector0,1|-ConnectorAll -aN|-a0,1,2|-aALL  
${megacli} -AdpSetConnectorMode -Internal|-External -ConnectorN|-Connector0,1|-ConnectorAll -aN|-a0,1,2|-aALL  
${megacli} -PhyErrorCounters -aN|-a0,1,2|-aALL  
${megacli} -DirectPdMapping -Enbl|-Dsbl|-Dsply -aN|-a0,1,2|-aALL  
    Note: The directly connected drives can be specified as [:S] 
    Wildcard '?' can be used to specify the enclosure ID for the drive in the 
      only enclosure without direct connected device or the direct connected 
      drives with no enclosure in the system.
    The following options may be given at the end of any command above: 
      [-Silent] [-AppLogFile filename] [-NoLog]
Last revision on April 24 2017 11:11:59