Everyone who has worked with specific vendors servers for awhile has likely encountered megacli. This is the comman line tool to manage your RAID controller and disks. Since often I'll only end up doing this every six months or so, I usually forget the syntax and decided to write it down here.
Install megacli
sudo apt-get install megacli
Common Parameters
Controller Syntax: -aN
This is telling MegaCLI the adapter ID. Don't use the ALL flag, always use this because you'll get in a bad habit and forget which boxes have multiple controllers
Physical drive: -PhysDrv [E:S]
I hate this format. E is the enclosure drive ID where the drive is and S is the slot number starting at 0. You get this info with the megacli -EncInfo -aALL
Virtual drive: -Lx
Used for specifying the virtual drive (where x is a number starting with zero or the string all).
Information Commands
Get Controller Information:
megacli -AdpAllInfo -aALL
megacli -CfgDsply -aALL
megacli -adpeventlog -getevents -f lsi-events.log -a0 -nolog
Common Operations
Replace drive:
- Set the drive offline with
megacli -PDOffline -PhysDrv[E:S] -aN
- Mark the drive as missing:
megacli -PDMarkMissing -PhysDrv [E:S] -aN
- Get the drive ready to yank out:
megacli -PDPrpRmv -PhysDrv [E:S] -aN
- Change/replace the drive:
megacli -PdReplaceMissing -PhysDrv[E:S] -ArrayN -rowN -aN
- Start the drive:
megacli -PDRbld -Start -PhysDrv [E:S] -aN
Fix Drive marked as "foreign" when inserted:
This happens when you steal a drive from a existing RAID to put in your more critical array. I know, you've never done anything so evil. Anyway when you need to here's how you do it.
- Flip to good:
megacli -PDMakeGood -PhysDrv [E:S] -aALL
- Clear the foreign (that feels offensive but we're gonna move on):
megacli -CfgForeign -Clear -aALL
Shut the stupid alarm off for good
megacli -AdpSetProp AlarmDsbl -aALL