MegaRaid

MegaCLI: useful commands September 12, 2011 Frederik

Recently I installed a server with a Supermicro SMC2108 RAID adapter, which is actually a LSI MegaRAID SAS 9260. LSI created a command line utility called MegaCLI for Linux to manage this adapter. You can download it from their support pages. The downloaded archive contains an RPM file. I installed mc and rpm on Debian with apt-get, and then extracted the MegaCli64 binary (for x86_64) to /usr/local/sbin, and the libsysfs.so.2.0.2 from the Lib_utils RPM to /opt/lsi/3rdpartylibs/x86_64/ (that’s the location where MegaCli64 looks for this library).

Here are some useful commands: View information about the RAID adapter

For checking the firmware version, battery back-up unit presence, installed cache memory and the capabilities of the adapter:

View information about the battery backup-up unit state
 * 1) MegaCli64 -AdpAllInfo -aAll

View information about virtual disks
 * 1) MegaCli64 -AdpBbuCmd -aAll

Useful for checking RAID level, stripe size, cache policy and RAID state:

View information about physical drives
 * 1) MegaCli64 -LDInfo -Lall -aALL

Patrol read
 * 1) MegaCli64 -PDList -aALL

Patrol read is a feature which tries to discover disk error before it is too late and data is lost. By default it is done automatically (with a delay of 168 hours between different patrol reads) and will take up to 30% of IO resources.

To see information about the patrol read state and the delay between patrol read runs:
 * 1) MegaCli64 -AdpPR -Info -aALL

To find out the current patrol read rate, execute
 * 1) MegaCli64 -AdpGetProp PatrolReadRate -aALL

To reduce patrol read resource usage to 2% in order to minimize the performance impact:
 * 1) MegaCli64 -AdpSetProp PatrolReadRate 2 -aALL

To disable automatic patrol read:
 * 1) MegaCli64 -AdpPR -Dsbl -aALL

To start a manual patrol read scan:
 * 1) MegaCli64 -AdpPR -Start -aALL

To stop a patrol read scan:
 * 1) MegaCli64 -AdpPR -Stop -aALL

You could use the above commands to run patrol read in off-peak times. Migrate from one RAID level to another

In this example, I migrate the virtual disk 0 from RAID level 6 to RAID 5, so that the disk space of one additional disk becomes available. The second command is used to make Linux detect the new size of the RAID disk.

Extending an existing RAID array with a new disk
 * 1) /usr/local/sbin/MegaCli64 -LDRecon -Start -r5 -L0 -a0
 * 2) echo 1 > /sys/block/sda/device/rescan

./MegaCli64 -LDRecon -Start -r5 -Add -PhysDrv[32:3] -L0 -a0 Create a new RAID 5 virtual disk from a set of new hard drives

First we need to now the enclosure and slot number of the hard drives we want to use for the new RAID disk. You can find them out by the first command. Then I add a virtual disk using RAID level 5, followed by the list of drives I want to use, specified by enclosure:slot syntax.

Extending an existing RAID array with a new disk
 * 1) MegaCli64 -PDList -aALL | egrep 'Adapter|Enclosure|Slot|Inquiry'
 * 2) MegaCli64 -CfgLdAdd -r5'[252:5,252:6,252:7]' -a0

First check the enclosure device ID and the slot number of the newly added disk with the command above. Then we reconstruct the logical drive, adding the new drive. For a RAID 5 array this command is used:

View reconstruction progress
 * 1) MegaCli64 -LDRecon -Start -r5 -Add -PhysDrv[32:3] -L0 -a0

When reconstructing a RAID array, you can check its progress with this command.
 * 1) MegaCli64 -LDRecon ShowProg L0 -a0

(replace L0 by L1 for the second virtual disk, and so on) Configure write-cache to be disabled when battery is broken

Change physical disk cache policy
 * 1) MegaCli64 -LDSetProp NoCachedBadBBU -LALL -aALL

If your system is not connected to a UPS, you should disable the physical disk cache in order to prevent data loss.


 * 1) MegaCli -LDGetProp -DskCache -LAll -aALL

To enable it (only do this if you have a UPS and redundant power supplies):


 * 1) MegaCli -LDGetProp -DskCache -LAll -aALL