smartctl & megaraid: how to find the right device node for an adapter #

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.


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


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