MegaCli: Get the /dev/sd* device name for a logical drive
Solution 1
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 -class disk
...
*-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
Solution 2
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
Solution 3
For anyone stumbling on this question and using storcli
(successor of MegaCLI
), you can map a virtual drive to the disk seen by the operating system with the following:
$ /opt/MegaRAID/storcli/storcli64 /c0/v0 show all | grep NAA
SCSI NAA Id = 6001676001750006201086de0bd7f605
$ ls -al /dev/disk/by-id/ | grep wwn-0x6001676001750006201086de0bd7f605
lrwxrwxrwx 1 root root 9 Jan 23 10:55 wwn-0x6001676001750006201086de0bd7f605 -> ../../sdk
Tested with storcli-1.21.06
download at: https://docs.broadcom.com/docs/1.21.06_StorCLI
Solution 4
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
Solution 5
I have been dealing with this across a number of new servers recently and I've come up with a solution! We are not using RAID on the "RAID" card, just using the SAS drives as JBOD. The /dev/disk/by-id
mappings are off by one (or a few) from the SAS Address
. This seems bizarre, but it works across dozens of servers I've tested it on. I have also received independent confirmation that this works for others.
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. After using this in production for a while I also added megablink
and megaunblink
for controlling the "come fix me" blinking LED. That feature has saved me from pulling the wrong drive out of the server. Please submit bug reports on github.
[ image thanks to Scott Vrable ]
Related videos on Youtube
twblamer
Updated on September 18, 2022Comments
-
twblamer almost 2 years
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
-
twblamer about 12 yearsI 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 uplshw
. Thanks for the tip though. -
twblamer about 12 yearsI downloaded that zip and it doesn't look like it works for my card+OS, unfortunately. Seems like I might be stuck.
-
Ricardo Gomes about 12 yearsMay I ask why you chose to configure each disk as a RAID 0 logical drive? You should normally be able to access each disk individually without creating logical drives.
-
twblamer about 12 yearsLooks like JBOD is disabled on the adapter by default, but I can enable it:
./MegaCli64 -AdpSetProp -EnableJBOD 1 -a0
-
chicks almost 10 yearsI 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 over 9 yearsBased on a bug report and subsequent fixes I have released a new version of
megamap
on github. -
Michael Galaxy over 8 yearsShort and sweet.
-
SvennD over 8 yearsThis works great, even at Centos 6, thanks!
-
Vincent S. Cojot over 8 yearsPlease note that the tool was accepted and merged upstream so a more recent version is at: raw.githubusercontent.com/eLvErDe/hwraid/master/wrapper-scripts/…
-
biocyberman over 7 yearsWow, this save me a headache. Works beautifully. Thanks
-
Vincent S. Cojot almost 7 yearsPlease report any issues at: github.com/eLvErDe/hwraid/issues