MegaCLI – Manage LSI MegaRAID Controllers

MegaCLI (short for MegaRAID Command Line Interface) is a command-line utility developed by Broadcom (formerly LSI/Avago) to configure, monitor, and maintain hardware RAID arrays. It’s a vital tool for system administrators working with Dell, Supermicro, IBM, and other enterprise systems that include LSI MegaRAID controllers.

In this article, you’ll learn how to install MegaCLI, run important RAID management commands, and monitor drive health, with real-world examples to make your life easier.

What is MegaCLI?

MegaCLI is a proprietary tool that allows full control over LSI RAID controllers via the command line. With it, you can:

  • Check RAID array status
  • View and manage logical/physical drives
  • Create or delete RAID arrays
  • Monitor drive health (SMART)
  • Identify failed drives
  • Replace or rebuild drives

It’s especially useful for headless Linux servers or remote management where GUI tools aren’t an option.

Installing MegaCLI on Linux

MegaCLI is not available in typical Linux repos. You’ll need to download it from Broadcom’s official support page.

🔗 Download MegaCLI (Broadcom/LSI)

Search for “MegaCLI” or use the product ID for your controller.

Installation Steps (Ubuntu/Debian):

Download and Install MegaCli package for Ubuntu:

wget http://hwraid.le-vert.net/debian/pool-stretch/megacli/megacli_8.07.14-2%2BDebian.stretch.9.9_amd64.deb

dpkg -i megacli_8.07.14-2%2BDebian.stretch.9.9_amd64.deb

Basic Command Structure

MegaCLI uses a very specific syntax:

MegaCli -<Command> -a<Adapter Number|ALL>

Example:

MegaCli -AdpAllInfo -aALL

Let’s break down some of the most useful commands.

View RAID Controller Information

MegaCli -AdpAllInfo -aALL

Displays adapter info, firmware version, memory, and more.

Check Physical Drive Status

MegaCli -PDList -aALL

Lists all connected physical drives, their slots, health, temperatures, etc.

Check Logical Drive (RAID Volume) Status

MegaCli -LDInfo -Lall -aALL

Shows logical drives (RAID 0,1,5,6,10), size, state (Optimal, Degraded), and stripe sizes.

Rebuild a Failed Drive

First, identify the failed drive using:

MegaCli -PDList -aALL

Then start the rebuild:

MegaCli -PDRbld -Start -PhysDrv [E:S] -aN

Where [E:S] = Enclosure:Slot
Example:

MegaCli -PDRbld -Start -PhysDrv [32:1] -a0

Identify Physical Drive (Blink LED)

Use this to identify a drive physically in your server:

MegaCli -PdLocate -start -physdrv [E:S] -aN

Stop blinking:

MegaCli -PdLocate -stop -physdrv [E:S] -aN

Clear Config (⚠️ WARNING: Destroys Data)

MegaCli -CfgClr -a0

Always double-check before running any destructive commands.

Create RAID Array

Example: Create a RAID 1 using disks in slot 0 and 1

MegaCli -CfgLdAdd -r1 [252:0,252:1] -a0

You can replace r1 with r0, r5, etc., depending on your desired RAID level.

Save MegaCLI Output to File

MegaCli -AdpAllInfo -aALL > raid_status.txt

Useful for support or monitoring scripts.

Scheduled Health Check Script (Sample)

#!/bin/bash
LOGFILE="/var/log/megacli_raid_status.log"
DATE=$(date)
echo "=== RAID Check at $DATE ===" >> $LOGFILE
/usr/sbin/MegaCli -LDInfo -Lall -aALL >> $LOGFILE
/usr/sbin/MegaCli -PDList -aALL >> $LOGFILE

Run this via a cronjob daily or weekly.

MegaCLI vs StorCLI vs PercCLI

  • MegaCLI – Legacy CLI, widely used but complex syntax.
  • StorCLI – Newer, easier to use, preferred for newer controllers.
  • PercCLI – Dell-customized CLI for their PERC RAID cards.

Output Interpretation

When you run MegaCli -PDList -aALL, here are key outputs:

  • Firmware state: Online/Unconfigured(bad)
  • Media Error Count
  • Predictive Failure Count
  • Raw Size
  • Drive Temperature

Look for drives that are not in “Online” state or have high error counts.

Common Issues

  • Command not found: Use ./MegaCli64 or set path.
  • Access denied: Run as root or use sudo.
  • Missing drivers: Some distros may require kernel modules (megaraid_sas).

Conclusion

MegaCLI remains a powerful and flexible utility for managing LSI-based RAID controllers, despite its steep learning curve. From checking disk health to configuring RAID arrays, MegaCLI enables complete control over your server storage infrastructure. Whether you’re replacing failed disks or automating RAID health checks, it’s an essential part of any sysadmin’s toolkit.

While newer tools like StorCLI are gaining popularity, MegaCLI is still widely supported across legacy systems and production environments.

Scroll to Top