Skip to content

Instantly share code, notes, and snippets.

@dw72
Forked from mvanvuuren/Megacli_cheatsheet.md
Last active April 15, 2025 11:41
Show Gist options
  • Save dw72/856e42ed9505a844cce125a75180c6cc to your computer and use it in GitHub Desktop.
Save dw72/856e42ed9505a844cce125a75180c6cc to your computer and use it in GitHub Desktop.
MegaCLI cheatsheet

Inside the tarball or zip file you’ll find an RPM archive which contains the megacli and megacli64 binaries (will be installed to /opt/MegaRAID/megacli).

Please note

This emergency cheat sheet is not exhaustive, but it should be sufficient in most cases. For a complete reference either call megacli -h or refer to the manual at: LSI megacli Manual

While there are a lot of different parameters for megacli, some of them are always identical. These are described here in short.


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’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 physical 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.


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).


Controller information

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

Enclosure information

megacli -EncInfo -aALL

Virtual drive information

megacli -LDInfo -Lall -aALL

Physical drive information

megacli -PDList -aALL
megacli -PDInfo -PhysDrv [E:S] -aALL

Battery backup information

megacli -AdpBbuCmd -aALL

Controller management

Silence active alarm

megacli -AdpSetProp AlarmSilence -aALL

Disable alarm

megacli -AdpSetProp AlarmDsbl -aALL

Enable alarm

megacli -AdpSetProp AlarmEnbl -aALL

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 the Span Reference you get using:

megacli -CfgDsply -aALL

The number N of the row parameter is the Physical Disk in that span or array starting with zero (it’s not the physical disk’s slot!).


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

Bad to good (or back to good as I like to call it)

megacli -PDMakeGood -PhysDrv[E:S] -aN

This changes drive in state Unconfigured-Bad to Unconfigured-Good.


Walkthrough: Change/replace a drive

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

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

Prepare drive for removal

megacli -PDPrpRmv -PhysDrv [E:S] -aN

Change/replace the drive

If you’re using hot spares then the replaced drive should become your new hot spare drive:

megacli -PDHSP -Set -PhysDrv [E:S] -aN

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment