MegaCli command examples
Determine disk states
$ sudo /opt/MegaCli -PDList -aALL
This will return information for each disk attached to each array in the system. For example:
Adapter #0 Enclosure Device ID: 32 Slot Number: 3 Device Id: 3 Sequence Number: 2 Media Error Count: 0 Other Error Count: 0 Predictive Failure Count: 2 Last Predictive Failure Event Seq Number: 11785 Raw Size: 70007MB [0x88bb93a Sectors] Non Coerced Size: 69495MB [0x87bb93a Sectors] Coerced Size: 69376MB [0x8780000 Sectors] Firmware state: Online SAS Address(0): 0x5000c5000c1bcaed SAS Address(1): 0x0 Connected Port Number: 3(path0) Inquiry Data: SEAGATE ST973451SS SM043PD1Z56T
In this example, the drive is getting ready to fail (Predictive Failure Count: 2) but, hasn't yet (Firmware state: Online).
Taking a disk offline for replacement
Continuing with the drive example above, we now want to replace this drive before it becomes a problem but, we need to do that safely. Placing the drive in an offline state will do that.
sudo /opt/MegaCli -PDOffline -PhysDrv \[32:3\] -a0
The 32 is the "Enclosure Device ID", the 3 is the "Slot Number" and the 0 is the "Adapter #".
Is the new drive usable?
After the failed drive has been replaced, it needs to synchronize with the rest of the array before it can be used. This is called a "rebuild". If you want to see the progress of this run:
sudo /opt/MegaCli -PDRbld -ShowProg -PhysDrv \[32:3\] -a0
Again, the 32 is the "Enclosure Device ID", the 3 is the "Slot Number" and the 0 is the "Adapter #" from the drive example above.