4

I can list physical drives on all megaraid adapters using:

megacli -PDList -aALL 

This will display an adapter # for each adapter, and then list the physical drives attached to them.

The individual devices in the PDList output also have a Device Id which is used for the smartctl command e.g. for device id 3:

smartctl -a -d sat+megaraid,3 /dev/sda

Both commands use the same device id, so no problem there. But how can we properly map the adapter # to a device node?

Running smartmontools-5.43-1.el6 on CentOS 6. Looking at the source code it seems it needs a bus number / host_no obtained from ioctl SG_GET_SCSI_ID or SCSI_IOCTL_GET_BUS_NUMBER on the named device node. Is this the same number used as "Adapter #" in MegaCLI output?

Actually in my case I could probably get away with hardcoding it to /dev/sda, but I'd like to know if there's a better way.

4

This is how I've done it before. There might be better ways.

Get the PCI bus ID for the adapter from MegaCLI:

/opt/MegaRAID/MegaCli/MegaCli64 -adpgetpciinfo -a0 | grep Bus
Bus Number      : 2

In this case, BUS=2. Then look through the PCI table for devices on that BUS, and look for the 'hostX' entry:

ls /sys/bus/pci/devices/0000\:0${BUS}\:00.0/ | grep host
host0

So, HOST=host0.
Now look for the target in that host directory

ls /sys/bus/pci/devices/0000\:0${BUS}\:00.0/${HOST}/ | grep target
target0:2:0

Our SCSI target ID is 0:2:0 (host 0:channel 2:target 0).

Match SCSI target with the output of lsscsi

# lsscsi 
[0:2:0:0]    disk    LSI      MR9271-8i        3.24  /dev/sda 
[1:2:0:0]    disk    LSI      MR9271-8i        3.24  /dev/sdb 
[2:0:0:0]    disk    ATA      INTEL SSDSC2BA80 5DV1  /dev/sdc

MegaCLI adapter a0 corresponds to /dev/sda (0:2:0 is ~= 0:2:0:0 in this case. The final 0 is the LUN ID)

If I follow the same method for adapter a1 I get a bus number of 3, host1, and a target value of 1:2:0, which maps to /dev/sdb.

  • I no longer have access to the hardware to check so I'm going to take your word for it. Thanks for answering! – lmz Dec 1 '14 at 8:14
4

Run smartctl --scan to print all devices attached including the device id and RAID type:

# smartctl  --scan
/dev/sda -d scsi # /dev/sda, SCSI device
/dev/bus/0 -d megaraid,0 # /dev/bus/0 [megaraid_disk_00], SCSI device
/dev/bus/0 -d megaraid,1 # /dev/bus/0 [megaraid_disk_01], SCSI device
/dev/bus/0 -d megaraid,2 # /dev/bus/0 [megaraid_disk_02], SCSI device

Another output:

# smartctl  --scan
/dev/sda -d scsi # /dev/sda, SCSI device
/dev/bus/0 -d megaraid,5 # /dev/bus/0 [megaraid_disk_05], SCSI device
/dev/bus/0 -d megaraid,7 # /dev/bus/0 [megaraid_disk_07], SCSI device

Here, megaraid is the RAID type and 5,7 are the device IDs

1

Node can be found this way:

# megacli -pdlist -a0| grep 'Device Id'
Device Id: 11
Device Id: 12
# smartctl -a -d megaraid,11 /dev/sda

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.