MegaCLI Monitor RAID Status

Introduction

MegaCLI is a software tool for managing and maintaining hardware RAID. It allows you to retrieve all information about the current RAID controller, including the controller model, RAID array type, status of each disk in the array, etc. Typically, it is difficult to determine the current status of hard disks; this is usually done via physical inspections by data center staff. Is there a way to check and verify this using software? MegaCLI can accomplish this. Generally, we determine whether there are issues with disks in the array based on two values: Media Error Count: 0 and Other Error Count: 0. Media Error Count indicates potential disk errors, such as bad sectors; if this value is non-zero, it requires attention—the higher the value, the greater the risk. Other Error Count indicates that a disk may be loose and might need to be reinserted. MegaCLI can scan all disks in the array. We can detect relevant parameters via scripts to notify administrators.

I. Download MegaCLI

Currently, the company's DB database runs on IBM servers. Download directly from the official IBM site. If

for other servers, use the respective official download sites or the LSI website for downloads. Generally, the package is universal and applies to both 32-bit and 64-bit operating system platforms. 

Download URL: ftp://download2.boulder.ibm.com/ecc/sar/CMA/XSA/ibm_utl_sraidmr_megacli-8.00.48_linux_32-64.zip

II. Installation

#unzip ibm_utl_sraidmr_megacli-8.00.48_linux_32-64.zip
#cd linux
# rpm -ivh Lib_Utils-1.00-09.noarch.rpm  MegaCli-8.00.48-1.i386.rpm

III. Command Usage and Parameters

Click (here) to collapse or expand

  1. Command usage:
  2. #/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL Check RAID level
  3. #/opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -aALL Check RAID controller information
  4. #/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL View hard disk information
  5. #/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -aAll View battery information
  6. #/opt/MegaRAID/MegaCli/MegaCli64 -FwTermLog -Dsply -aALL View RAID controller logs
  7. #/opt/MegaRAID/MegaCli/MegaCli64 -adpCount [Display number of adapters]
  8. #/opt/MegaRAID/MegaCli/MegaCli64 -AdpGetTime –aALL [Display adapter time]
  9. #/opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -aAll [Display all adapter information]
  10. #/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LALL -aAll [Display all logical disk group information]
  11. #/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aAll [Display all physical information]
  12. #/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuStatus -aALL |grep 'Charger Status' [Check charging status]
  13. #/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuStatus -aALL [Display BBU status information]
  14. #/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuCapacityInfo -aALL [Display BBU capacity information]
  15. #/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuDesignInfo -aALL [Display BBU design parameters]
  16. #/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuProperties -aALL [Display current BBU attributes]
  17. #/opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -aALL [Display RAID controller model, RAID settings, and disk-related information]
  18. 3. Changes in tape status during the process of removing and inserting disks.
  19. Device |Normal|Damage|Rebuild|Normal
  20. Virtual Drive |Optimal|Degraded|Degraded|Optimal
  21. Physical Drive |Online|Failed –> Unconfigured|Rebuild|Online
  22. 4. View disk cache policy
  23. #/opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -L0 -a0
  24. or
  25. #/opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -L1 -a0
  26. or
  27. #/opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -LALL -a0
  28. ro
  29. #/opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -LALL -aALL
  30. ro
  31. #/opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -DskCache -LALL -aALL
  32. 5. Set disk cache policy
  33. Cache policy explanation:
  34. WT (Write through
  35. WB (Write back)
  36. NORA (No read ahead)
  37. RA (Read ahead)
  38. ADRA (Adaptive read ahead)
  39. Cached
  40. Direct
  41. Example:
  42. #/opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp WT|WB|NORA|RA|ADRA -L0 -a0
  43. or
  44. #/opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp -Cached|-Direct -L0 -a0
  45. or
  46. enable / disable disk cache
  47. #/opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp -EnDskCache|-DisDskCache -L0 -a0
  48. 6. Create a RAID 5 array composed of physical disks 2, 3, and 4, with physical disk 5 as the hot spare.
  49. #/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r5 [1:2,1:3,1:4] WB Direct -Hsp[1:5] -a0
  50. 7. Create an array without specifying a hot spare
  51. #/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r5 [1:2,1:3,1:4] WB Direct -a0
  52. 8. Delete an array
  53. #/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdDel -L1 -a0
  54. 9. Add a disk online
  55. #/opt/MegaRAID/MegaCli/MegaCli64 -LDRecon -Start -r5 -Add -PhysDrv[1:4] -L1 -a0
  56. 10. After array creation, there is an initialization synchronization process; you can view its progress.
  57. #/opt/MegaRAID/MegaCli/MegaCli64 -LDInit -ShowProg -LALL -aALL
  58. Or display dynamically in a text-based visual interface
  59. #/opt/MegaRAID/MegaCli/MegaCli64 -LDInit -ProgDsply -LALL -aALL
  60. 11. View background initialization progress of the array
  61. #/opt/MegaRAID/MegaCli/MegaCli64 -LDBI -ShowProg -LALL -aALL
  62. Or display dynamically in a text-based visual interface
  63. #/opt/MegaRAID/MegaCli/MegaCli64 -LDBI -ProgDsply -LALL -aALL
  64. 12. Designate the 5th disk as a global hot spare
  65. #/opt/MegaRAID/MegaCli/MegaCli64 -PDHSP -Set [-EnclAffinity] [-nonRevertible] -PhysDrv[1:5] -a0
  66. 13. Specify a dedicated hot spare for a specific array
  67. #/opt/MegaRAID/MegaCli/MegaCli64 -PDHSP -Set [-Dedicated [-Array1]] [-EnclAffinity] [-nonRevertible] -PhysDrv[1:5] -a0
  68. 14. Delete global hot spare
  69. #/opt/MegaRAID/MegaCli/MegaCli64 -PDHSP -Rmv -PhysDrv[1:5] -a0
  70. 15. Offline/Online a physical disk
  71. #/opt/MegaRAID/MegaCli/MegaCli64 -PDOffline -PhysDrv [1:4] -a0
  72. #/opt/MegaRAID/MegaCli/MegaCli64 -PDOnline -PhysDrv [1:4] -a0
  73. 16. View physical disk rebuild progress
  74. #/opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -ShowProg -PhysDrv [1:5] -a0
  75. Or display in dynamic visual text interface
  76. #/opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -ProgDsply -PhysDrv [1:5] -a0
  77. Changes in tape status during the process of removing and inserting disks:
  78. Device |Normal|Damage|Rebuild|Normal
  79. Virtual Drive |Optimal|Degraded|Degraded|Optimal
  80. Physical Drive |Online|Failed –> Unconfigured|Rebuild|Online

1. View RAID level

MegaCLI Monitor RAID Status

2. View RAID controller information, mainly outputting some configuration information of the RAID controller

MegaCLI Monitor RAID Status

RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0
Size : 1.086 TB
State : Optimal
Strip Size : 128 KB
Number Of Drives per span: 4 // Indicates that 4 physical disks form one RAID1 disk group
Span Depth : 2 // Indicates that 2 RAID1 disk groups form a RAID10

3. View information for all hard disks

/opt/MegaCli64  -pdlist –aALL

MegaCLI Monitor RAID Status

4. View current RAID cache status. If the RAID cache status is set to WB, attention must be paid to battery discharge. Set the battery discharge mode to automatic learning mode

/opt/MegaRAID/MegaCli/MegaCli64   -ldgetprop  -dskcache -lall  -aall

MegaCLI Monitor RAID Status

5. Related settings for RAID batteries

View battery status information (Display BBU Status Information)
MegaCli -AdpBbuCmd -GetBbuStatus -aN|-a0,1,2|-aALL
MegaCli -AdpBbuCmd -GetBbuStatus -aALL

View battery capacity (Display BBU Capacity Information)
MegaCli -AdpBbuCmd -GetBbuCapacityInfo -aN|-a0,1,2|-aALL
MegaCli -AdpBbuCmd -GetBbuCapacityInfo –aALL

View battery design parameters (Display BBU Design Parameters)
MegaCli -AdpBbuCmd -GetBbuDesignInfo -aN|-a0,1,2|-aALL
MegaCli -AdpBbuCmd -GetBbuDesignInfo –aALL

View current battery properties (Display Current BBU Properties)
MegaCli -AdpBbuCmd -GetBbuProperties -aN|-a0,1,2|-aALL
MegaCli -AdpBbuCmd -GetBbuProperties –aALL

Set battery to learning mode as cycling mode (Start BBU Learning Cycle)
Description Starts the learning cycle on the BBU.
No parameter is needed for this option.
MegaCli -AdpBbuCmd -BbuLearn -aN|-a0,1,2|-aALL

Set disk cache mode and access method (Change Virtual Disk Cache and Access Parameters)
Description Allows you to change the following virtual disk parameters:
-WT (Write through), WB (Write back): Selects write policy.
-NORA (No read ahead), RA (Read ahead), ADRA (Adaptive read ahead): Selects read policy.
-Cached, -Direct: Selects cache policy.
-RW, -RO, Blocked: Selects access policy.
-EnDskCache: Enables disk cache.
-DisDskCache: Disables disk cache.
MegaCli -LDSetProp { WT | WB|NORA |RA | ADRA|-Cached|Direct} |
{-RW|RO|Blocked} |
{-Name[string]} |
{-EnDskCache|DisDskCache} –Lx |
-L0,1,2|-Lall -aN|-a0,1,2|-aALL
MegaCli -LDSetProp WT -L0 -a0

Display disk cache and access method (Display Virtual Disk Cache and Access Parameters)
MegaCli -LDGetProp -Cache | -Access | -Name | -DskCache -Lx|-L0,1,2|
-Lall -aN|-a0,1,2|-aALL
Displays the cache and access policies of the virtual disk(s):
-WT (Write through), WB (Write back): Selects write policy.
-NORA (No read ahead), RA (Read ahead), ADRA (Adaptive read ahead): Selects read policy.
-Cache, -Cached, Direct: Displays cache policy.
-Access, -RW, -RO, Blocked: Displays access policy.
-DskCache: Displays physical disk cache policy.

Megaraid Essentials: Using LSI Megaraid allows effective monitoring of RAID. Other vendors such as HP and IBM also have their own RAID APIs
MegaCli -ldinfo -lall -aall
Query RAID level, number of disks, capacity, and stripe size.
MegaCli -cfgdsply -aALL |grep Policy
Query controller cache policy
MegaCli -LDSetProp WB -L0 -a0
Set write-back function
MegaCli -LDSetProp CachedBadBBU -L0 -a0
Set to maintain WB function even if the battery fails
MegaCli -AdpBbuCmd -BbuLearn a0
Manual charging
MegaCli -FwTermLog -Dsply -aALL 
Query logs
Display adapter count: MegaCli -adpCount
Display all adapter information: MegaCli -AdpAllInfo -aAll
Critical Disks : 0 
Failed Disks : 0 
Display all logical disk group information: MegaCli -LDInfo -LALL -aAll
Display all physical information: MegaCli -PDList -aAll
Media Error Count: 0
Other Error Count: 0
View charging status: MegaCli -AdpBbuCmd -GetBbuStatus -aALL
Learn Cycle Requested : No
Fully Charged : Yes
Display BBU (backup battery) status information: MegaCli -AdpBbuCmd -GetBbuStatus -aALL
Display BBU capacity information: MegaCli -AdpBbuCmd -GetBbuCapacityInfo -aALL
Display BBU design parameters: MegaCli -AdpBbuCmd -GetBbuDesignInfo -aALL
Display current BBU properties: MegaCli -AdpBbuCmd -GetBbuProperties -aALL
Display RAID controller model, RAID settings, and disk information: MegaCli -cfgdsply -aALL
View cache policy settings: MegaCli -cfgdsply -aALL |grep -i Policy
Current Cache Policy: WriteBack, ReadAheadNone, Direct, Write Cache OK if Bad BBU
View battery charge progress percentage: MegaCli -AdpBbuCmd -GetBbuStatus -aALL 
Different states for various devices and disks:
Device |Normal|Damage|Rebuild|Normal
Virtual Drive |Optimal|Degraded|Degraded|Optimal
Physical Drive |Online|Failed –> Unconfigured|Rebuild|Online

6. Detect RAID disk status via script

Script under Linux

#!/bin/bash

#check raid disk status

MEGACLI="/opt/MegaRAID/MegaCli/MegaCli64 "

$MEGACLI -pdlist -aALL  | grep "Firmware state" | awk -F : '{print $2}' | awk -F , '{print $1}' >/tmp/fireware.log

$MEGACLI -pdlist -aALL  | grep -E "Media Error|Other Error" | awk -F : '{print $2}' >/tmp/disk.log

for i in `cat < /tmp/disk.log`

do

if [ $i -ne 0 ]

        then

curl "http://xxxxxxB&state=ALARM&description=raid_disk_error"

fi

done

for i in `cat < /tmp/fireware.log`

do

if [ $i !=  Online ]

        then

curl "http://xxxxxxstate=ALARM&description=raid_disk_offline"

fi

done

Script under Windows

The tools used for the Windows script are some software from the gnu for windows platform, such as bash, grep, awk, cat

Call the script directly via bash

For example: G:\raid_check\unixtools>bash.exe G:\disk.sh

#check raid disk status

MEGACLI="//G/raid_check/MegaCli.exe"

GREP="//G/raid_check/unixtools/grep.exe"

AWK="//G/raid_check/unixtools/awk.exe"

CAT="//G/raid_check/unixtools/cat.exe"

CURL="//G/raid_check/unixtools/curl.exe"

$MEGACLI -pdlist -aALL  | $GREP "Firmware state" |$AWK -F: '{print $2}' |$AWK -F , '{print $1}' >//c/fireware.log

$MEGACLI -pdlist -aALL  | $GREP -E "Media Error|Other Error" | $AWK -F : '{print $2}' > //c/disk.log

for i in `$CAT c:/disk.log`

do

if [ $i -ne 0 ]

        then

$CURL "http://xxxxxx&description=raid_disk_error"

fi

done

for i in `$CAT c:/fireware.log`

do

if [ $i != Online ]

        then

$CURL "http://xxxxx&state=ALARM&description=raid_disk_offline"

fi

Images localized into English for illustration; labels may vary by product version.

5 views Updated 2026-11-07

More in this groupRAID Card CLI Tools

View all 10 in this group

Can't find an answer?

Upload a log for AI diagnosis, or ask the AI assistant directly in the console.