Wednesday, September 13, 2017

MegaCli64 Commands and its purpose


MegaCli64 Commands and its purpose


The MegaCli64 command has a ridiculous amount of command line switches, and the syntax is a bit bizarre as well.
The following commands I found useful when trying to physically identify a failed disk and replace it.

General Parameters

·         Adapter parameter -aN
The parameter -aN (where N is a number starting with zero or the string ALL) specifies the adapter ID. If you have only one controller it’s safe to use ALL instead of a specific ID, but you’re encouraged to use the ID for everything 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 virtual drive (see 5).
·         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).

Failed drive(s):

/opt/MegaRAID/MegaCli/MegaCli64 -LDPDInfo -aAll | grep -i 'inquiry\|firmware state'
NOTE: This will output two lines for each disk; "status" followed by the disk serial, model, and firmware info.





Add disk in existing RAID Array:
/opt/MegaRAID/MegaCli/MegaCli64 -LDRecon -Start -r5 -Add -PhysDrv[252:5] -L0 -a0
Show Reconstructing progress:
/opt/MegaRAID/MegaCli/MegaCli64 -LDRecon ShowProg L0 -a0

Gather information
·         Controller information
     MegaCli -AdpAllInfo -aALL
     MegaCli -CfgDsply -aALL

Get Information from All Physical Disks
The -a command line switch specifies the Array ID, in this case All Array IDs.
MegaCli64 -PdList -aAll
MegaCli -PDInfo -PhysDrv [E:S] -aALL

·         Enclosure information
     MegaCli -EncInfo -aALL

Get Virtual Disk Information

The -a command line switch specifies the Array ID, in this case All Array IDs.
    MegaCli64 -LDInfo -Lall -aAll

 

Get the Number of Virtual Drives Configured on Each Adapter

The -a command line switch specifies the Array ID, in this case All Array IDs.
MegaCli64 -LdGetNum -aAll

Get the Number of Array Controllers

MegaCli64 -adpCount

Blink Hard Drive Lights

Start Blinking

The -a command line switch specifies the Array ID, in this case Array ID 0.
MegaCli64 -PdLocate -start -physdrv[<ENCLOSURE>:<DRIVE>] -a0

Stop Blinking

The -a command line switch specifies the Array ID, in this case Array ID 0.
MegaCli64 -PdLocate -stop -physdrv[<ENCLOSURE><DRIVE>] -a0

Set Dedicated Hot Spare

The following physical drive was Unconfigured(good):
Enclosure Device ID: 4
Slot Number: 16
Device Id: 154
Sequence Number: 1
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
Raw Size: 140014MB [0x11177328 Sectors]
Non Coerced Size: 139502MB [0x11077328 Sectors]
Coerced Size: 139392MB [0x11040000 Sectors]
Firmware state: Unconfigured(good)
SAS Address(0): 0x500000e117951c52
SAS Address(1): 0x0
Connected Port Number: 0(path0) 
Inquiry Data: FUJITSU MBE2147RC       D905D304PB30AAGJ
When looking at all of the physical drives by running MegaCli64 -PdList -aAll, Array #: 0, 1, 2, 3, 4 were missing a hotspare.
The following command added the Unconfigured(good) physical drive above as a dedicated hotspare:
The -a command line switch specifies the Array ID, in this case Array ID 0.
MegaCli64 -PDHSP -Set -Dedicated -Array0,1,2,3,4 -PhysDrv [4:16] -a0

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
The number N of the Array parameter is from the "Span Reference:" line you get using MegaCli -CfgDsply -aALL, minus the 0x0 part.  For VSM systems it's normally 0.  The number N of the rowparameter is the Physical Disk in that span or array starting with zero (it can be but is not always the physical disk’s slot!).
·         Rebuild drive - Drive status should be "Firmware state: Rebuild"
     MegaCli -PDRbld -Start -PhysDrv [E:S] -aN
     MegaCli -PDRbld -Stop -PhysDrv [E:S] -aN
     MegaCli -PDRbld -ShowProg -PhysDrv [E:S] -aN    
     MegaCli -PDRbld -ProgDsply -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
·         Bad to good
     MegaCli -PDMakeGood -PhysDrv[E:S] -aN
     Changes drive in state Unconfigured-Bad to Unconfigured-Good.
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: Rebuild a Drive that is marked 'Foreign' when Inserted:
·         Bad to good
    MegaCli -PDMakeGood -PhysDrv [E:S]  -aALL
·         Clear the foreign setting
     MegaCli -CfgForeign -Clear -aALL
·         Set global hot spare
     MegaCli -PDHSP -Set -PhysDrv [E:S] -aN
Walkthrough: Change/replace a drive
1. Set the drive offline, if it is not already offline due to an error
     MegaCli -PDOffline -PhysDrv [E:S] -aN
2. Mark the drive as missing
     MegaCli -PDMarkMissing -PhysDrv [E:S] -aN
3. Prepare drive for removal
     MegaCli -PDPrpRmv -PhysDrv [E:S] -aN
4. Change/replace the drive
5. If you’re using hot spares then the replaced drive should become your new hot spare drive
     MegaCli -PDHSP -Set -PhysDrv [E:S] -aN
6. 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

Display all Adapters Configuration without log
This command shows Atapter, Logical Drive, Physical Drive etc.. all in one.
#MegaCli64 -CfgDsply -aALL -nolog
Display Adapters properties
# MegaCli64 -AdpAllInfo -aALL
Get Number of Adapter
#MegaCli64 -adpCount
Controller Count: 1.
List all physical disks
The -a command line switch specifies the Adapter ID, in this case Adapter 0.
Note:[-aALL] option assumes that the parameters specified are valid for all the Adapters.
In the example below, it only show physical disk number, size and disk type.
# MegaCli64 -pdList -a0 | grep -i -E "slot|RAW Size|pd type"
Slot Number: 0
PD Type: SAS
Raw Size: 558.911 GB [0x45dd2fb0 Sectors]
Slot Number: 1
PD Type: SAS
Raw Size: 558.911 GB [0x45dd2fb0 Sectors]
Slot Number: 2
PD Type: SAS
Raw Size: 558.911 GB [0x45dd2fb0 Sectors]
Slot Number: 3
PD Type: SAS
Raw Size: 558.911 GB [0x45dd2fb0 Sectors]
Create a Logical Drive
Query physical disk info first
#MegaCli64 -PDList -aALL | egrep 'Adapter|Enclosure|Slot|Inquiry'
Adapter #0
Enclosure Device ID: 252
Slot Number: 0
Enclosure position: N/A
Inquiry Data: IBM-ESXSMBF2600RC SB2AEA00JHK4SB2ASB2ASB2A
Enclosure Device ID: 252
Slot Number: 1
Enclosure position: N/A
Inquiry Data: IBM-ESXSMBF2600RC SB2AEA00JHK1SB2ASB2ASB2A
Enclosure Device ID: 252
Slot Number: 2
Enclosure position: N/A
Inquiry Data: IBM-ESXSAL13SEB600 SB3534401NH4SB35SB35SB35
Enclosure Device ID: 252
Slot Number: 3
Enclosure position: N/A
Inquiry Data: IBM-ESXSAL13SEB600 SB35344031H4SB35SB35SB35
Create a Logical Drive
#MegaCli64 -CfgLdAdd -r1 '[252:2,252:3]' -a0
List Logical Drive info
The -L specifies the LD ID, -a specifies Adapter ID, same as the example above.
#MegaCli64 -LDInfo -Lall -aALL

Adapter 0 -- Virtual Drive Information:
Virtual Drive: 0 (Target Id: 0)
Name :
RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0
Size : 557.861 GB
Mirror Data : 557.861 GB
State : Optimal
Strip Size : 128 KB
Number Of Drives : 2
Span Depth : 1
Default Cache Policy: WriteBack, ReadAheadNone, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteBack, ReadAheadNone, Direct, No Write Cache if Bad BBU
Default Access Policy: Read/Write
Current Access Policy: Read/Write
Disk Cache Policy : Disabled
Encryption Type : None
Is VD Cached: No

Virtual Drive: 1 (Target Id: 1)
Name :
RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0
Size : 557.861 GB
Mirror Data : 557.861 GB
State : Optimal
Strip Size : 128 KB
Number Of Drives : 2
Span Depth : 1
Default Cache Policy: WriteBack, ReadAheadNone, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteBack, ReadAheadNone, Direct, No Write Cache if Bad BBU
Default Access Policy: Read/Write
Current Access Policy: Read/Write
Disk Cache Policy : Disabled
Encryption Type : None
Is VD Cached: No
In the case above, 2 LD were listed, with detail info such as raid level, size, strip size, cache policy etc..
Just want to get number of LD configured, here is it
#MegaCli64 -LdGetNum -aAll
Number of Virtual Drives Configured on Adapter 0: 2
View information about the battery backup-up unit state
#MegaCli64 -AdpBbuCmd -aAll
BBU status for Adapter: 0

BatteryType: iBBU08
Voltage: 4080 mV
Current: 0 mA
Temperature: 31 C
Battery State     : Operational

BBU Firmware Status:

  Charging Status              : None
  Voltage                                 : OK
  Temperature                             : OK
  Learn Cycle Requested                      : No
  Learn Cycle Active                      : No
  Learn Cycle Status                      : OK
  Learn Cycle Timeout                     : No
  I2c Errors Detected                     : No
  Battery Pack Missing                    : No
  Battery Replacement required            : No
  Remaining Capacity Low                  : No
  Periodic Learn Required                 : No
  Transparent Learn                       : No
  No space to cache offload               : No
  Pack is about to fail & should be replaced : No
  Cache Offload premium feature required  : No
  Module microcode update required        : No
BBU GasGauge Status: 0x0280
  Relative State of Charge: 100 %
  Charger System State: 1
  Charger System Ctrl: 0
  Charging current: 0 mA
  Absolute state of charge: 88 %
  Max Error: 0 %

  Battery backup charge time : 48 hours +

BBU Capacity Info for Adapter: 0

  Relative State of Charge: 100 %
  Absolute State of charge: 88 %
  Remaining Capacity: 1333 mAh
  Full Charge Capacity: 1336 mAh
  Run time to empty: Battery is not being discharged.
  Average time to empty: 2 Hour, 40 Min.
  Estimated Time to full recharge: Battery is not being charged.
  Cycle Count: 6

BBU Design Info for Adapter: 0

  Date of Manufacture: 02/29, 2012
  Design Capacity: 1500 mAh
  Design Voltage: 4100 mV
  Specification Info: 0
  Serial Number: 698
  Pack Stat Configuration: 0x0000
  Manufacture Name: LS36691
  Device Name: bq27541
  Device Chemistry: LION
  Battery FRU: N/A
  Transparent Learn = 0
  App Data = 0

BBU Properties for Adapter: 0

  Auto Learn Period: 30 Days
  Next Learn time: Sat Aug 23 01:57:06 2014

  Learn Delay Interval:0 Hours
  Auto-Learn Mode: Enabled
  BBU Mode = 4
Configure write-cache to be disabled when battery is broken
# MegaCli64 -LDSetProp NoCachedBadBBU -LALL -aALL
Change physical disk cache policy
To disable it at no UPS situation
# MegaCli -LDGetProp -DskCache -LAll -aALL
To enable it:
# MegaCli -LDGetProp -DskCache -LAll -aALL
Blink Hard Drive Lights
Sometime, if a disk not complete dead, you may not see a amber light
Start Blinking
MegaCli64 -PdLocate -start -physdrv[<ENCLOSURE>:<DRIVE>] -a0
Stop Blinking
MegaCli64 -PdLocate -stop -physdrv[<ENCLOSURE><DRIVE>] -a0
View reconstruction progress
When reconstructing a RAID array, you can check its progress with this command, in this case, Logical Drive 0, Adapter 0
# MegaCli64 -LDRecon ShowProg L0 -a0
Patrol read is a feature which tries to discover disk error before it is too late and data is lost. By default it is done automatically (with a delay of 168 hours between different patrol reads) and will take up to 30% of IO resources.
To see information about the patrol read state and the delay between patrol read runs:
# MegaCli64 -AdpPR -Info -aALL
To find out the current patrol read rate, execute
# MegaCli64 -AdpGetProp PatrolReadRate -aALL
To reduce patrol read resource usage to 2% in order to minimize the performance impact:
# MegaCli64 -AdpSetProp PatrolReadRate 2 -aALL
To disable automatic patrol read:
# MegaCli64 -AdpPR -Dsbl -aALL
To enable automatic patrol read:
#MegaCli64 -AdpPR -EnblAuto -aALL
To start a manual patrol read scan:
# MegaCli64 -AdpPR -Start -aALL
To stop a patrol read scan:
# MegaCli64 -AdpPR -Stop -aALL

Note: Use the above commands to run patrol read in off-peak times.


2 comments: