MegaCLI Cheat Sheet
Working with RAID controllers can be a daunting task, especially if you only need to do it occasionally. MegaCLI, a powerful command-line tool for managing RAID controllers and disks, can be particularly challenging due to its cryptic syntax. To simplify the process, I’ve compiled this cheat sheet of essential MegaCLI commands and tips for easy reference.
Installing MegaCLI
To install MegaCLI on a Debian-based system, use:
sudo apt-get install megacli
Common Parameters
Controller Syntax: -aN
- Use this to specify the adapter ID.
- Avoid using the
ALL
flag to prevent accidental changes across all controllers.
Physical Drive: -PhysDrv [E:S]
E
: Enclosure IDS
: Slot number (starting at 0).- Retrieve enclosure and slot information with:
megacli -EncInfo -aALL
Virtual Drive: -Lx
- Use to specify the virtual drive where
x
is a number starting at 0 or the stringall
.
Information Commands
Get Controller Information
- Display adapter details:
megacli -AdpAllInfo -aALL
- Show RAID configuration:
megacli -CfgDsply -aALL
- Export event logs:
megacli -adpeventlog -getevents -f lsi-events.log -a0 -nolog
Common Operations
Replace a Drive
- Set the drive offline:
megacli -PDOffline -PhysDrv[E:S] -aN
- Mark the drive as missing:
megacli -PDMarkMissing -PhysDrv [E:S] -aN
- Prepare for removal:
megacli -PDPrpRmv -PhysDrv [E:S] -aN
- Replace the drive and assign it:
megacli -PdReplaceMissing -PhysDrv[E:S] -ArrayN -rowN -aN
- Start the rebuild process:
megacli -PDRbld -Start -PhysDrv [E:S] -aN
Fix a “Foreign” Drive
- Mark the drive as good:
megacli -PDMakeGood -PhysDrv [E:S] -aALL
- Clear the foreign configuration:
megacli -CfgForeign -Clear -aALL
Disable the Alarm
If the alarm is causing unnecessary noise, turn it off:
megacli -AdpSetProp AlarmDsbl -aALL
Why This Matters
MegaCLI is a powerful yet complex tool, and knowing these commands can save you hours of frustration during critical maintenance tasks. Bookmark this cheat sheet for your next encounter with RAID management!
For more insights and tips, feel free to connect with me on LinkedIn, GitHub, or BlueSky.
Happy troubleshooting!