Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Let's say I know the drive I want is on Adapter 8, Virtual Drive 0, is there a way to get the Linux device name (e.g. /dev/sdt)? I am on RHEL 6.2.

-pdlist displays a WWN value for each physical drive, but that doesn't help much. -ldinfo doesn't print a WWN or any other identifying value.

# ./MegaCli64 -pdlist -a8 | grep WWN
WWN: 500051610003776C
WWN: 5000516100037BFC
WWN: 5000516100038090
WWN: 50005161000284F4
WWN: 5000516100037C0C
WWN: 5000516100037C5C
WWN: 50005161000310C8
WWN: 5000516100037F4C

# ls -1dt /dev/disk/by-id/wwn*
/dev/disk/by-id/wwn-0x600605b0043e52d01721fd142c12c84d
/dev/disk/by-id/wwn-0x600605b0043e52d01721fd142c0973e6
/dev/disk/by-id/wwn-0x600605b0043e52d01721fd132c002573
/dev/disk/by-id/wwn-0x600605b0043e52d01721fd122bf6e2f6
/dev/disk/by-id/wwn-0x600605b0043e52d01721fd122beda52a
/dev/disk/by-id/wwn-0x600605b0043e52d01721fd112be46f10
/dev/disk/by-id/wwn-0x600605b0043e52d01721fd112bdb3ffb
/dev/disk/by-id/wwn-0x600605b0043e52d01721fd102bd20f14

# ./MegaCli64 -v                       
 MegaCLI SAS RAID Management Tool  Ver 8.03.08 Mar 15, 2012
share|improve this question

5 Answers 5

up vote 4 down vote accepted

You should be able to compare the disk serial number from -pdlist with the output from lshw.

# MegaCLI -pdlist -a0 | grep "Inquiry Data:"
Inquiry Data:       XXXXXXXXXXXXHitachi YYYYYYYY                 ZZZZZZ
...

Then search the output of lshw for the serial number. The device name will be in the logical name field.

I can't verify this because all of my disks are in a volume.

Identifying Logical Drives

Compare the Target Id from MegaCLI with the scsi bus target for the device. In lshw it is bus info.

# MegaCli -ldinfo -Lall -aall 


Adapter 0 -- Virtual Drive Information:
Virtual Drive: 0 (Target Id: 0)
Name                :
RAID Level          : Primary-6, Secondary-0, RAID Level Qualifier-3
Size                : 7.275 TB
State               : Optimal
Strip Size          : 64 KB
Number Of Drives    : 6
Span Depth          : 1
Default Cache Policy: WriteBack, ReadAhead, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteBack, ReadAhead, Direct, No Write Cache if Bad BBU
Access Policy       : Read/Write
Disk Cache Policy   : Disabled
Ongoing Progresses:
  Check Consistency        : Completed 17%, Taken 89 min.
Encryption Type     : None


Virtual Drive: 1 (Target Id: 1)
Name                :
RAID Level          : Primary-6, Secondary-0, RAID Level Qualifier-3
Size                : 7.275 TB
State               : Optimal
Strip Size          : 64 KB
Number Of Drives    : 6
Span Depth          : 1
Default Cache Policy: WriteBack, ReadAhead, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteBack, ReadAhead, Direct, No Write Cache if Bad BBU
Access Policy       : Read/Write
Disk Cache Policy   : Disabled
Ongoing Progresses:
  Check Consistency        : Completed 17%, Taken 89 min.
Encryption Type     : None

From lshw:

# lshw
...
              *-enclosure UNCLAIMED
               description: SCSI Enclosure
               product: Bobcat
               vendor: LSI CORP
               physical id: 1.75.0
               bus info: scsi@0:1.117.0
               version: 0504
               configuration: ansiversion=5
          *-disk:0
               description: SCSI Disk
               product: MR9260-16i
               vendor: LSI
               physical id: 2.0.0
               bus info: scsi@0:2.0.0
               logical name: /dev/sda
               version: 2.12
               serial: svDASJ-f8kM-4qp5-BswW-3IKC-DDyA-djz8N7
               size: 7450GiB
               capacity: 7450GiB
               capabilities: lvm2
               configuration: ansiversion=5
          *-disk:1
               description: SCSI Disk
               product: MR9260-16i
               vendor: LSI
               physical id: 2.1.0
               bus info: scsi@0:2.1.0
               logical name: /dev/sdb
               version: 2.12
               serial: NHUvUy-1tm4-aGYW-g6DZ-t1Z9-gxW8-JhvFfL
               size: 7450GiB
               capacity: 7450GiB
               capabilities: lvm2
               configuration: ansiversion=5
share|improve this answer
    
I just tried this, but I have IBM drives and for me it looks like there's no correlation between the serial number that shows up in -pdlist and the serial number that shows up lshw. Thanks for the tip though. –  twblamer Apr 19 '12 at 16:05
    
It may be that your controller card is not exposing the real serial number and makes a volume serial number for each disk. –  Jeff Strunk Apr 19 '12 at 16:09
    
I should add this is a JBOD setup with each drive configured in a RAID0 array of one drive. So I would expect the physical drive's serial number to be hidden, but I'm wondering if I can get some info out of the logical drive config. –  twblamer Apr 19 '12 at 16:25
    
I just checked a bunch of MegaCLI options, but I couldn't find any logical drive serial numbers. –  Jeff Strunk Apr 19 '12 at 16:28
1  
Looks like JBOD is disabled on the adapter by default, but I can enable it: ./MegaCli64 -AdpSetProp -EnableJBOD 1 -a0 –  twblamer May 2 '12 at 20:23

I have been dealing with this across a number of new servers recently and I've come up with a solution that at least works for us. We are not using RAID on the card, just treating the drives as JBOD. They are all SAS drives. The /dev/disk/by-id mappings appear to be off-by-one from the SAS Address. This seems bizarre, but it works across 10 servers I've tested on.

https://github.com/chicks-net/megamap is a short Perl script that implements the discovery above. It produces a map of Linux drive sd* to megaRaid drive ID and also displays the WWN from Linux.

share|improve this answer
    
I have added a utility called megablink to the same github repo that will blink the bad drive for the field technician to easily find it. –  chicks Jul 27 '14 at 4:13
    
Based on a bug report and subsequent fixes I have released a new version of megamap on github. –  chicks Dec 2 '14 at 15:54

There is an alternate tool called lsiutil that has been discontinued. If it works for your card, it may be easier to use: http://www.lsi.com/downloads/Public/Obsolete/Obsolete%20Common%20Files/LSIUtil_1.62.zip

Once you select your controller card, option 42 is supposed to display the OS names. I use this on Solaris, and the disks are in real JBOD mode instead of a bunch of single disk RAID 0 logical drives.

share|improve this answer
    
I downloaded that zip and it doesn't look like it works for my card+OS, unfortunately. Seems like I might be stuck. –  twblamer Apr 19 '12 at 17:07

Instead of using lshw, I think you can just use /dev/disk/by-path to get the relationship between the scsi target id and the logical device name(sdX).

targetId=0;dev=`ls -l /dev/disk/by-path/ | grep -E "scsi-[0-9]:[0-9]:${targetId}:[0-9] " | awk '{print($11)}'`; echo ${dev##*\/}

  deviceId=$1
  ldPdInfo=`$MegaCommand -LdPdInfo -aALL | grep -E 'Virtual Drive|Device Id'`
  if [ $ldPdInfo ]; then
    targetId=`echo $ldPdInfo | awk '{a[NR]=$0} END {while (NR) print a[NR--]}' | awk "/Device Id: ${deviceId}$/,/Virtual Drive/" | grep -Eo 'Target Id: [0-9]' | grep -Eo '[0-9]'`
    dev=`ls -l /dev/disk/by-path/ | grep -E "scsi-[0-9]:[0-9]:${targetId}:[0-9] " | awk '{print($11)}'`
  else
    wwn=`$MegaCommand -PdList -aALL | awk "/Device Id: ${deviceId}$/,/WWN/" | grep "WWN" | awk '{print($2)}'`
    # wwn=`echo "obase=16;ibase=16; $wwn-1" | bc`
    dev=`ls -l /dev/disk/by-id/ | grep -i -E "wwn-0x${wwn:0:-1}[0-9a-z] " | awk '{print($11)}'`
  fi
  devName=${dev##*\/}
  echo $devName
share|improve this answer

I just added some support to my fork of megaclisas-status for matching the logical drive to an OS Native device. Here's an example output:

$ sudo ./megaclisas-status
-- Controller information --
-- ID | H/W Model                  | RAM    | Temp | Firmware     
c0    | LSI MegaRAID SAS 9271-8i   | 1024MB | 88C  | FW: 23.32.0-0009 
c1    | LSI MegaRAID SAS 9280-4i4e | 512MB  | N/A  | FW: 12.15.0-0205 

-- Array information --
-- ID | Type   |    Size |  Strpsz |   Flags | DskCache |  Status |  OS Path | InProgress   
c0u0  | RAID-1 |   1817G |  256 KB | ADRA,WT |  Enabled | Optimal | /dev/sda | None         
c0u1  | RAID-5 |  16370G |  512 KB | ADRA,WB |  Enabled | Optimal | /dev/sdb | None         
c1u0  | RAID-0 |    476G |  256 KB | ADRA,WT |  Enabled | Optimal | /dev/sdc | None         

-- Disk information --
-- ID   | Type | Drive Model                                  | Size     | Status          | Speed    | Temp | Slot ID  | LSI Device ID
c0u0p0  | HDD  | WD-WMC300422505WDC WD20EFRX-68AX9N0 80.00A80 | 1.817 TB | Online, Spun Up | 6.0Gb/s  | 31C  | [252:4]  | 17      
c0u0p1  | HDD  | WD-WMC300421817WDC WD20EFRX-68AX9N0 80.00A80 | 1.817 TB | Online, Spun Up | 6.0Gb/s  | 31C  | [252:5]  | 18      
c0u1p0  | HDD  | WD-WX41DA40LCE5WDC WD60EFRX-68MYMN1 82.00A82 | 5.456 TB | Online, Spun Up | 6.0Gb/s  | 32C  | [252:0]  | 15      
c0u1p1  | HDD  | WD-WX41DA40L42RWDC WD60EFRX-68MYMN1 82.00A82 | 5.456 TB | Online, Spun Up | 6.0Gb/s  | 31C  | [252:1]  | 12      
c0u1p2  | HDD  | WD-WX61DA4HAKFZWDC WD60EFRX-68MYMN1 82.00A82 | 5.456 TB | Online, Spun Up | 6.0Gb/s  | 32C  | [252:6]  | 14      
c0u1p3  | HDD  | WD-WX41DA40LEF1WDC WD60EFRX-68MYMN1 82.00A82 | 5.456 TB | Online, Spun Up | 6.0Gb/s  | 31C  | [252:7]  | 16      
c1u0p0  | SSD  | 0000000011310344CFE3M4-CT512M4SSD2 070H      | 476.4 Gb | Online, Spun Up | 6.0Gb/s  | N/A  | [252:1]  | 11      

-- Unconfigured Disk information --

The tool itself is available at: http://step.polymtl.ca/~coyote/dist/megaclisas-status/megaclisas-status

I hope this helps,

Vincent

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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