MegaCli:获取逻辑驱动器的/ dev / sd *设备名称


16

假设我知道我想要的驱动器位于适配器8,虚拟驱动器0上,是否可以获取Linux设备名称(例如/dev/sdt)?我正在使用RHEL 6.2。

-pdlist显示每个物理驱动器的WWN值,但这无济于事。-ldinfo不打印WWN或任何其他标识值。

# ./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

Answers:


10

您应该能够将的磁盘序列号-pdlist与的输出进行比较lshw

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

然后在的输出中搜索lshw序列号。设备名称将在logical name字段中。

我无法验证这一点,因为我所有的磁盘都在一个卷中。

识别逻辑驱动器

比较Target Id来自MegaCLI的与设备的scsi总线目标。在lshw里面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

从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

1
我只是尝试这样做,但我有IBM硬盘,对我来说好像已经昭示着最多的序列号之间没有相关性-pdlist和序列号显示出来lshw。谢谢你的小费。
twblamer

可能是您的控制器卡没有公开真实的序列号,而是为每个磁盘制作了卷序列号。
Jeff Strunk

我应该添加一个JBOD设置,每个驱动器都配置在一个驱动器的RAID0阵列中。因此,我希望可以隐藏物理驱动器的序列号,但是我想知道是否可以从逻辑驱动器配置中获取一些信息。
twblamer'4

1
看起来默认情况下适配器上已禁用JBOD,但我可以启用它:./MegaCli64 -AdpSetProp -EnableJBOD 1 -a0
twblamer'5

1
要仅显示磁盘,请使用:lshw -class disk
Dan Mazzini

7

我刚刚在megaclisas-status的分支中添加了一些支持,以将逻辑驱动器与OS Native设备进行匹配。这是示例输出:

$ 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 --

该工具本身可从以下网站获得:http : //step.polymtl.ca/~coyote/dist/megaclisas-status/megaclisas-status

我希望这有帮助,

文森特


即使在Centos 6上,它也很好用,谢谢!
SvennD

2
请注意,该工具已经被接受,合并上游所以较新的版本是:raw.githubusercontent.com/eLvErDe/hwraid/master/wrapper-scripts/...
文森特S. Cojot

哇,这让我头疼。做工精美。谢谢
biocyberman

尝试过,但是在os path列中只有数字
hek2mgl

请在以下网址
Vincent S. Cojot

6

对于在此问题上遇到麻烦并使用storcli(的后继产品MegaCLI)的任何人,可以使用以下命令将虚拟驱动器映射到操作系统所看到的磁盘:

$ /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

通过storcli-1.21.06下载进行测试:https : //docs.broadcom.com/docs/1.21.06_StorCLI


5

lshw我认为您可以使用而不是使用/dev/disk/by-path来获取scsi目标ID与逻辑设备名称(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

简短而甜美。
Michael R. Hines'1

3

最近,我已经在许多新服务器上处理了这个问题,并提出了一个解决方案!我们不在“ RAID”卡上使用RAID,而只是将SAS驱动器用作JBOD。所述/dev/disk/by-id映射是通过关闭从所述一个(或几个)SAS Address。这似乎很奇怪,但是它可以在我测试过的数十台服务器上使用。我也收到了独立的确认书,证明这对其他人有用。

megamap是一个简短的Perl脚本,用于实现上述发现。它会生成Linux驱动器sd*到MegaRaid驱动器ID 的映射,并显示Linux的WWN。在生产中使用了一段时间后,我还添加了一个闪烁的LED megablinkmegaunblink用于控制“来解决我”问题。该功能使我免于从服务器中拉出错误的驱动器。请在github上提交错误报告。

商标[图片感谢Scott Vrable ]


我加入了一个叫megablink相同的GitHub库,将闪烁盘为现场技术人员很容易地找到它。
小鸡

基于错误报告和后续修复,我megamap在github上发布了新版本。
小鸡

2

Harry的命令非常有帮助,但是我需要更进一步并确定pci设备,因为我的配置中有多个SAS适配器。想我应该分享:

  vdisk=1

  MegaCommand=/opt/MegaRAID/CmdTool2/CmdTool2

  vendor_id=$($MegaCommand -AdpAllInfo -aALL \
    | grep -E "^Vendor Id" \
    | sed 's/.*: //g' )

  device_id=$($MegaCommand -AdpAllInfo -aALL \
    | grep -E "^Device Id" \
    | sed 's/.*: //g' )

  pci_address=$(lspci -n \
    | grep "$vendor_id" \
    | grep "$device_id" \
    | awk '{print $1}' )

  dev_sdx=$($MegaCommand -LDInfo -LALL -aALL \
    | grep "^Virtual Drive: $vdisk (" \
    | tr -d ")" \
    | sed 's/.*Target Id: //g')

  dev_sdx=$(ls -l /dev/disk/by-path/ \
    | grep -E "$pci_address-scsi-[0-9]:[0-9]:$dev_sdx:[0-9] " \
    | grep sd  \
    | sed 's/.*\///g')

  echo "Found /dev/ as /dev/$dev_sdx"

1

有一个替代工具lsiutil叫停使用。如果它适用于您的卡,则可能更易于使用:http : //www.lsi.com/downloads/Public/Obsolete/Obsolete%20Common%20Files/LSIUtil_1.62.zip

选择控制器卡后,选项42应该显示OS名称。我在Solaris上使用此磁盘,并且磁盘处于实际JBOD模式,而不是一堆单磁盘RAID 0逻辑驱动器。


我下载了该zip文件,不幸的是,它似乎不适用于我的card + OS。好像我可能被卡住了。
twblamer'4

1

我正在研究同一件事,发现了这篇文章-http: //sysadm.pp.ua/linux/monitoring-systems/python-lsi-megaraid-monitoring.html。您可以使用python和bash脚本为您提供所有需要的信息:

root@s11:~# bash megaraid.sh log

-- Array information --
-- ID | Type   |    Size |  Strpsz | Flags | DskCache |   Status |  OS Path | InProgress
c0u0  | RAID-5 |   2725G |   64 KB | RA,WT |  Default | Degraded | /dev/sda | None
-- Disk information --
-- ID   | Type | Drive Model                               | Size     | Status          | Speed    | Temp | Slot ID  | Device ID
c0u0p2  | HDD  | SEAGATE ST1000NM0001 0002Z1N4K2PY         | 930.3 Gb | Failed          | 6.0Gb/s  | 29C  | [4:2]    | 15
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.