硬盘SN与硬盘槽位信息及盘符的对应关系

前述

很多情况下,我们需要从OS下查询硬盘的SN,来定位硬盘的物理槽位。如:系统下硬盘报错,对于系统下的硬盘的报错是以硬盘的盘符体现的,而这种情况下我们需要知道该盘符对应硬盘的SN和具体的物理槽位以实现故障硬盘的更换。因此,今天将对这个过程做个介绍,我们将介绍常用OS,比如Linux、ESXi下定位硬盘的一些方法。

Linux

几个工具

Sg_inq

This  utility by default sends a SCSI INQUIRY command to the given device and then outputs the response. All SCSI devices are meant to respond to a "standard" INQUIRY command with at least a 36 byte response (in SCSI 2 and higher). An INQUIRY is termed as "standard" when both the EVPD and CmdDt (now obsolete) bits are clear.

Stocli

Stocli是broadcom Raid/HBA卡的一个CLI工具,支持Windows/ESXi/Linux多种操作系统,可以实现硬盘信息的一些查询。

smartctl

smartctl  controls  the  Self-Monitoring,  Analysis and Reporting Technology (SMART) system built into most ATA/SATA and SCSI/SAS hard drives and solid-state drives.  The purpose of SMART is to monitor the reliability of the hard drive and predict drive failures, and to carry out different types of drive self-tests.  smartctl also supports some features not  related  to  SMART.  This  version of smartctl is compatible with ACS-3, ACS-2, ATA8-ACS, ATA/ATAPI-7 and earlier standards (see REFERENCES below).

几种方法

注:SN作为媒介,来参照不同的信息。

通过Smartctl或Sg_inq和Stocli工具以SN为媒介获取盘符跟硬盘槽位之间的关系

[root@localhost~]# sg_inq /dev/sda

standard INQUIRY:

  PQual=0  Device_type=0  RMB=0  version=0x06  [SPC-4]

  [AERC=0]  [TrmTsk=0]  NormACA=0  HiSUP=1  Resp_data_format=2

  SCCS=0  ACC=0  TPGS=0  3PC=0  Protect=1  [BQue=0]

  EncServ=0  MultiP=1 (VS=0)  [MChngr=0]  [ACKREQQ=0]  Addr16=0

  [RelAdr=0]  WBus16=0  Sync=0  Linked=0  [TranDis=0]  CmdQue=1

  [SPI: Clocking=0x0  QAS=0  IUS=0]

    length=164 (0xa4)  Peripheral device type: disk

Vendor identification: LENOVO 

Product identification: AL15SEB060N   

Product revision level: TB55

Unit serial number: 58U0A1AWFHSF

[root@localhost ~]# smartctl  -i /dev/sda

smartctl 6.5 2016-05-07 r4318 [x86_64-linux-3.10.0-862.el7.x86_64] (local build)

Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===

Vendor:              LENOVO

Product:              AL15SEB060N

Revision:            TB55

Compliance:          SPC-4

User Capacity:        600,127,266,816 bytes [600 GB]

Logical block size:  512 bytes

Rotation Rate:        10500 rpm

Form Factor:          2.5 inches

Logical Unit id:      0x50000398a8a01dd5

Serial number:        58U0A1AWFHSF

Device type:          disk

Transport protocol:  SAS (SPL-3)

Local Time is:        Fri Jul 15 19:49:27 2022 CST

SMART support is:    Available - device has SMART capability.

SMART support is:    Enabled

Temperature Warning:  Enabled

[root@localhost~]# ./onecli/ts_tools/storcli_x64  /c0/eall/sall show all|egrep  "^Drive|^SN" 

Drive /c0/e0/s4 :

Drive /c0/e0/s4 - Detailed Information :

Drive /c0/e0/s4 State :

Drive /c0/e0/s4 Device attributes :

SN = 58U0A1K5FHSF

Drive /c0/e0/s4 Policies/Settings :

Drive /c0/e0/s6 :

Drive /c0/e0/s6 - Detailed Information :

Drive /c0/e0/s6 State :

Drive /c0/e0/s6 Device attributes :

SN = 58U0A1BKFHSF

Drive /c0/e0/s6 Policies/Settings :

Drive /c0/e0/s2 :

Drive /c0/e0/s2 - Detailed Information :

Drive /c0/e0/s2 State :

Drive /c0/e0/s2 Device attributes :

SN = 58U0A1AWFHSF

Drive /c0/e0/s2 Policies/Settings :

Drive /c0/e0/s3 :

Drive /c0/e0/s3 - Detailed Information :

Drive /c0/e0/s3 State :

Drive /c0/e0/s3 Device attributes :

SN = 58U0A19PFHSF

Drive /c0/e0/s3 Policies/Settings :

Drive /c0/e0/s5 :

Drive /c0/e0/s5 - Detailed Information :

Drive /c0/e0/s5 State :

Drive /c0/e0/s5 Device attributes :

SN = 58U0A1ACFHSF

Drive /c0/e0/s5 Policies/Settings :

Drive /c0/e0/s7 :

Drive /c0/e0/s7 - Detailed Information :

Drive /c0/e0/s7 State :

Drive /c0/e0/s7 Device attributes :

SN = 58U0A1KAFHSF

Drive /c0/e0/s7 Policies/Settings :

注:通过SN的一致性信息可以查看出来sda盘符对应slot2硬盘。

通过Stocli和Lsscsi工具以wwn为媒介获取盘符跟硬盘槽位之间的关系

[root@localhost ~]# ./ts_tools/storcli_x64 /c0 show all|grep -i -E "Device attributes|WWN"

Drive /c0/e0/s4 Device attributes :

WWN = 50000398a8a0e241                  sdc

Drive /c0/e0/s2 Device attributes :

WWN = 50000398a8a01dd5                sda

Drive /c0/e0/s7 Device attributes :

WWN = 50000398a8a0e275                sdf

Drive /c0/e0/s3 Device attributes :

WWN = 50000398a8a010a9                sdb

Drive /c0/e0/s5 Device attributes :

WWN = 50000398a8a01b41                sdd

Drive /c0/e0/s6 Device attributes :

WWN = 50000398a8a0205d                sde

[root@localhost ~]# lsscsi -w

[0:0:0:0]    disk    0x50000398a8a01dd5                  /dev/sda

[0:0:1:0]    disk    0x50000398a8a010a9                  /dev/sdb

[0:0:2:0]    disk    0x50000398a8a0e241                  /dev/sdc

[0:0:3:0]    disk    0x50000398a8a01b41                  /dev/sdd

[0:0:4:0]    disk    0x50000398a8a0205d                  /dev/sde

[0:0:5:0]    disk    0x50000398a8a0e275                  /dev/sdf

[0:0:6:0]    enclosu         

通过Smartctl和Stocli工具以WWN为媒介获取盘符跟硬盘槽位之间的关系

[root@localhost ~]# smartctl -a /dev/sda|grep -i "Logical Unit id"

Logical Unit id:      0x50000398a8a01dd5

[root@sr570-1102-9102 ~]# ./onecli/ts_tools/storcli_x64  /c0/eall/sall show  all|grep -i 50000398a8a01dd5 -A 5 -B 10

Predictive Failure Count = 0

S.M.A.R.T alert flagged by drive = No

Drive /c0/e0/s2 Device attributes :

=================================

Manufacturer Id = LENOVO 

Model Number = AL15SEB060N   

NAND Vendor = NA

SN = 58U0A1AWFHSF

WWN = 50000398a8a01dd5

Firmware Revision = TB55

Raw size = 558.911 GB [0x45dd2faf Sectors]

Coerced size = 558.911 GB [0x45dd2faf Sectors]

Non Coerced size = 558.911 GB [0x45dd2faf Sectors]

Device Speed = Unknown

注:smartctl命令输出了盘符跟wwn的匹配关系,stocli命令输出了wwn跟slot的对应关系,结合两者输出就可以建立起盘符跟slot的对应关系了。

通过Smartctl和BMC工具以SN为媒介获取盘符跟槽位的对应关系

注:前提是首先系统下通过smartctl知道硬盘的SN。

[root@localhost ~]# smartctl -i /dev/sda

smartctl 6.5 2016-05-07 r4318 [x86_64-linux-3.10.0-862.el7.x86_64] (local build)

Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===

Vendor:              LENOVO

Product:              AL15SEB060N

Revision:            TB55

Compliance:          SPC-4

User Capacity:        600,127,266,816 bytes [600 GB]

Logical block size:  512 bytes

Rotation Rate:        10500 rpm

Form Factor:          2.5 inches

Logical Unit id:      0x50000398a8a01dd5

Serial number:        58U0A1AWFHSF

Device type:          disk

Transport protocol:  SAS (SPL-3)

Local Time is:        Fri Jul 15 20:24:58 2022 CST

SMART support is:    Available - device has SMART capability.

SMART support is:    Enabled

Temperature Warning:  Enabled

system> storage -show disk[1-2] info

Product Name: AL15SEB060N

State: JBOD

Slot No.: 2

Disk Type: SAS

Media Type: HDD

Health Status: Normal

Capacity: 558.912GB

Speed: 12.0Gb/s

Current Temperature: 23C

Rotation Rate: 10500RPM

Media Error Count: 0

Other Error Count: 0

Predication Fail Count: 0

Remaining Life: N/A

FDE Capable: No

Secured: No

Manufacture: Toshiba

Device ID: 3

Enclosure ID: 0x0000

Machine Type:

Model:

Serial No.: 58U0A1AW

FRU No.: 00YK014

Part No.: D7A01863

注:Smartctl命令输出盘符跟SN的对应关系,BMC工具输出SN跟slot的对应关系,结合两者就可以建立盘符跟slot的对应关系。

ESXi系统

通过esxcli命令直接定位槽位

[root@localhost:~] esxcli storage core device list |grep naa

naa.600062b2039dab8029f0e420d7f2d964

  Display Name: Local Lenovo Disk (naa.600062b2039dab8029f0e420d7f2d964)

  Devfs Path: /vmfs/devices/disks/naa.600062b2039dab8029f0e420d7f2d964

naa.600062b2039dab80299f2fce682df661

  Display Name: Local Lenovo Disk (naa.600062b2039dab80299f2fce682df661)

  Devfs Path: /vmfs/devices/disks/naa.600062b2039dab80299f2fce682df661

naa.5000c500c14b27bb

  Display Name: Local LENOVO Disk (naa.5000c500c14b27bb)

  Devfs Path: /vmfs/devices/disks/naa.5000c500c14b27bb

naa.55cd2e41514592ce

  Display Name: Local ATA Disk (naa.55cd2e41514592ce)

  Devfs Path: /vmfs/devices/disks/naa.55cd2e41514592ce

[root@localhost:~] esxcli storage core device physical get -d naa.5000c500c14b27bb

  Physical Location: enclosure 1, slot 6

[root@localhost:~] esxcli storage core device physical get -d naa.55cd2e41514592ce

  Physical Location: enclosure 1, slot 4

注:通过esxcli 的命令可以直接定位硬盘的slot槽位,这块需要说明的是硬盘得是JBOD模式。

通过esxcli命令点亮 硬盘指示灯定位硬盘槽位

点亮硬盘定位灯

[root@localhost:~] esxcli storage core device set -l locator -d naa.5000c500c14b27bb

关闭硬盘定位灯

[root@localhost:~] esxcli storage core device set -l off  -d naa.5000c500c14b27bb


通过stocli和esxcli命令以sas address为媒介配合定位硬盘槽位

[root@localhost:~] esxcli storage core path list |egrep -i "Device: naa.|Target Identifier"

  Device: naa.5000cca0ab0333d4

  Target Identifier: sas.5000cca0ab0333d5

  Device: naa.5000cca0ab03207c

  Target Identifier: sas.5000cca0ab03207d

  Device: naa.55cd2e41514592ce

  Target Identifier: sas.300062b2039dab88

  Target Identifier: sata.0:2

  Device: naa.5000c500c14b27bb

  Target Identifier: sas.5000c500c14b27b9

  Target Identifier: sas.300162b2039dab80

  Device: naa.600062b2039dab80299f2fce682df661

  Target Identifier: sas.609f2fce682df661

[root@localhost:~] /opt/lsi/storcli/storcli /c0/eall/sall show all |egrep -i "Device attributes|WWN|Active|sas address"

Drive /c0/e134/s0 Device attributes :

WWN = 55cd2e4150c85da3

Port Status Linkspeed SAS address       

  0 Active 6.0Gb/s  0x300062b2039dab81

Drive /c0/e134/s1 Device attributes :

WWN = 55cd2e4150c85dad

Port Status Linkspeed SAS address       

  0 Active 6.0Gb/s  0x300062b2039dab83

Drive /c0/e134/s2 Device attributes :

WWN = 5000CCA0AB03207F

Port Status Linkspeed SAS address       

  0 Active 12.0Gb/s  0x5000cca0ab03207d

  1 Active 12.0Gb/s  0x0               

Drive /c0/e134/s3 Device attributes :

WWN = 5000CCA0AB0333D7

Port Status Linkspeed SAS address       

  0 Active 12.0Gb/s  0x5000cca0ab0333d5

  1 Active 12.0Gb/s  0x0               

Drive /c0/e134/s4 Device attributes :

WWN = 55cd2e41514592ce

Port Status Linkspeed SAS address       

  0 Active 6.0Gb/s  0x0               

  1 Active 6.0Gb/s  0x300062b2039dab88

Drive /c0/e134/s6 Device attributes :

WWN = 5000C500C14B27B8

Port Status Linkspeed SAS address       

  0 Active 12.0Gb/s  0x5000c500c14b27b9

  1 Active 12.0Gb/s  0x0            

注:ESXi下esxcli storage core path list 输出中的Target Identifier跟stocli 输出的sas address为匹配的,这样就可以建立esxi naa number>>esxi Target Identifier>> stocli sas address>>disk physical slot的对应关系,然后就可以建立naa number>>physical slot number的对应关系了。

[root@localhost:~] sh disk_placement.sh

disk_placement.sh: line 1: script: not found

=============Physical disks placement==============

naa.600062b2039dab80299f2fce682df661

naa.600062b2039dab80299f2fce682df661 is not a physical device

====================================================

naa.5000c500c14b27bb

  Physical Location: enclosure 1, slot 6

====================================================

naa.5000cca0ab0333d4

  Physical Location: enclosure 1, slot 3

====================================================

naa.55cd2e41514592ce

  Physical Location: enclosure 1, slot 4

====================================================

naa.5000cca0ab03207c

  Physical Location: enclosure 1, slot 2

====================================================

ESXi查询物理磁盘槽位的脚本

脚本案例

# Script to obtain the placement of the physical disk by naa on ESXi hosts

# Author: Jorluis Perales, VxRail TSE 2 @ Dell EMC

# Version 1.0

#

# Do not change anything below this line

# --------------------------------------

echo "=============Physical disks placement=============="

echo ""

esxcli storage core device list | grep "naa" | awk '{print $1}' | grep "naa" | while read in; do

echo "$in"

esxcli storage core device physical get -d "$in"

sleep 1

echo "===================================================="

done

运行结果

[root@localhost:~] sh disk_placement.sh

disk_placement.sh: line 1: script: not found

=============Physical disks placement==============

naa.600062b2039dab8029f0e420d7f2d964

naa.600062b2039dab8029f0e420d7f2d964 is not a physical device

====================================================

naa.600062b2039dab80299f2fce682df661

naa.600062b2039dab80299f2fce682df661 is not a physical device

====================================================

naa.5000c500c14b27bb

  Physical Location: enclosure 1, slot 6

====================================================

naa.55cd2e41514592ce

  Physical Location: enclosure 1, slot 4

====================================================

备注:此脚本为引用网上他人案例,如侵犯到您的权益请您及时联系,谢谢。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,240评论 6 498
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,328评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,182评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,121评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,135评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,093评论 1 295
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,013评论 3 417
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,854评论 0 273
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,295评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,513评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,678评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,398评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,989评论 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,636评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,801评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,657评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,558评论 2 352

推荐阅读更多精彩内容